[postgis-users] [OT] Extract data from within polygons - not in Postgis

chlists at me.com chlists at me.com
Wed Sep 10 05:05:11 PDT 2008


Hi list,
apologies for an off-topic question, but some of you osgeo wizards  
might know an answer for my question. I need some help to do some  
geoprocessing _outside_ PostGIS using available open source tools.

I have two shapefiles - the first one containing 'master' polygons,  
the second one can contain random features (lines, polygons or  
points). I now want to iterate through all polygons of the first  
shapefile and extract the features from the second file which are  
located within a given master polygon. The extracted features should  
also get some a new attribute based on which master polygon they are  
located in. So essentially it is a  simple iteration over a 'within'  
query.

Can this be done without converting the shapefiles to a different  
format using any of the existing open source tools (ogr2ogr, geos,  
shapely)? I would prefer to use Python, and if possible, the solution  
needs to be cross-platform (OS X, Win). If not, what would be the best  
way to do this, preserving the attributes of the shapefiles?

Any pointers greatly appreciated.

TIA,
Chris




More information about the postgis-users mailing list