I'm sorry, but I'm terribly new to the GIS scene (and PostGIS & QGis). I have loaded a whole bunch of OpenStreetMap data into a PostGIS database and successfully drawn a map using Mapnik. Now I want to explore the data in my PostGIS database using QGis.

I have successfully connected QGis to my remote PostGis DB and QGis lists the OSM tables. The query builder also displays all sorts of OpenStreetMap attributes and values.

My issue comes when clicking the "Add" button: I assume that QGis is trying to load the complete DB table, this step takes very long (and could be eating a lot of expensive South African bandwidth). I am really just interested in my tiny university campus for testing purposes. I don't yet know how to use the query builder to limit QGis' DB query to a certain latitute/longitude bounding box.

The QGis user manual wasn't helpful to solve this nooby question, sorry. Thanks!

  • You say you loaded OSM data into PostGIS. Why not have a local DB and access that instead of wasting any "expensive SA bandwidth"?
    – underdark
    Jun 19, 2011 at 21:57
  • Part of my honours project is building a "spatial object layer" for a multiplayer mobile game server. Since running that server on campus brings a lot of proxy issues, I decided to use a micro EC2 instance. But I should probably run a local copy for dev purposes, too.
    – rdrey
    Jun 19, 2011 at 23:39

2 Answers 2


You can limit the load with "Build Query" button on the "Add Postgis table dialog". On the bottom where it says "SQL where clause" write:

the_geom && ST_SetSRID(ST_MakeBox2D(ST_Point(14,43),ST_Point(16,46)),4326)

Replace points for the BBOX of your choice. This will work assuming that your geometry column is the_geom, otherwise, replace that with you geometry column name.

  • I'm assuming that the_geom is "way" in OpenStreetMap data I've imported via osm2pgsql. But I'm still reading the OSM wiki for details. I should also read more postgis tutorials, I guess. Thanks for the help!
    – rdrey
    Jun 19, 2011 at 23:45

I don't know if there is a option to limit the request to the canvas bounding box. If not it make sense to have it, so you may want to file a ticket in the QGIS bug tracker.


Selecting by bounding box with PostGIS

you can easily create a custom query using postgis functions. You can use also plugins like the "RT Sql Layer" to create/store/reuse your queries.

  • thanks, the link is useful! I'm not sure whether this constitutes a bug or missing feature, though.
    – rdrey
    Jun 19, 2011 at 23:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.