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 am looking for a solution to retrieve the geometry(ies) from a polygon/multipolygon within a bounding box in a GeoDjango application.

The application I am developing has a requirement to serve out tiles of geographical data, and many of our geometries are very large and span across multiple tiles. To reduce the payload of each tile I would like to splice(cut) a geometry shape(s) from a bounding box.

I am storing Planet.OSM data in a PostGIS database.

Any suggestions would be greatly appreciated!

Thanks

share|improve this question
add comment

1 Answer 1

If you are working with a GeoQuerySet, you can call the intersection() method with a geometry argument (e.g. your bounding box) to return the geometries from your GeoQuerySet that are intersected by the geometry (bounding box) you provided. If you need to use a raw query, try the corresponding ST_Intersection method of PostGIS. In either case, you should initially filter your results to those that are intersected by the bounding box. To quote the ST_Intersection reference:

ST_Intersection in conjunction with ST_Intersects is very useful for clipping geometries such as in bounding box, buffer, region queries where you only want to return that portion of a geometry that sits in a country or region of interest.

share|improve this answer
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.