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

Obe, Regina robe.dnd at cityofboston.gov
Wed Sep 10 05:18:48 PDT 2008


Chris,
I presume you are looking for a command-line solution given the examples
you provided below?

I've been using OpenJump a lot lately - mostly for ad-hoc PostGIS
queries, but it does support ESRI shape files as well and cursory glance
of the menu options seems to suggest it fits your below requirements,
but its a cross platform desktop open source tool (not a command-line
tool).

Things like Transfer Attributes, various functions - Union, Union by
attribute,Aggregate, Intersection you can apply against 2 datasets.

It is based on JTS code which GEOS is a port of, so at the very least
looking at the code base may give you some ideas on how to leverage GEOS
in Python to do what you are looking for. 

Hope that helps,
Regina

-----Original Message-----
From: postgis-users-bounces at postgis.refractions.net
[mailto:postgis-users-bounces at postgis.refractions.net] On Behalf Of
chlists at me.com
Sent: Wednesday, September 10, 2008 8:05 AM
To: PostGIS Users Discussion
Subject: [postgis-users] [OT] Extract data from within polygons - not
inPostgis

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

_______________________________________________
postgis-users mailing list
postgis-users at postgis.refractions.net
http://postgis.refractions.net/mailman/listinfo/postgis-users
-----------------------------------------
The substance of this message, including any attachments, may be
confidential, legally privileged and/or exempt from disclosure
pursuant to Massachusetts law. It is intended
solely for the addressee. If you received this in error, please
contact the sender and delete the material from any computer.




More information about the postgis-users mailing list