Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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!

share|improve this question
    
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 '11 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 '11 at 23:39
add comment

2 Answers

up vote 2 down vote accepted

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.

share|improve this answer
    
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 '11 at 23:45
add comment

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.

Meanwhile

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.

share|improve this answer
    
thanks, the link is useful! I'm not sure whether this constitutes a bug or missing feature, though. –  rdrey Jun 19 '11 at 23:41
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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