3

I currently use PostGIS as a backbone for a lot of spatial functions I perform in python scripts. Specifically taking several shapefile geometries and seeing if they intersect, and then sorting them into seperate directories. I upload the shapefiles using shp2pgsql and then correlate them using ST_Intersects and then sort them using os/shutil functions in the script.

My problem is one of our teams works only on government networks and cannot get postgres/postGIS approved by their system admins. Is there a python module/function out there that performs the same correlation of geometries as ST_Intersects without the need of postgres? Or if I need to write this myself, is there a site for algorithms pertaining to geometries. For example if I have an upper left and a lower right coordinate, how can I compute the other two points. I'm not asking for anyone to write code for me, just some help being pointed in the right direction.

Also all datums performed in WGS 1984

AlienAnarchist
  • 186
  • 4
  • 15
  • You might get better responses if you delete this and post on gis.stackexchange.com instead. Consider phrasing at least the title in a way that people who know Python and GIS but not PostGIS will understand, since they're the people most likely to be able to help you but won't necessarily know what ST_Intersects is. – Craig Ringer Apr 17 '14 at 00:02

1 Answers1

2

There are many tools to read Shapefiles, which you can use to get their extents or bounds. These can be used to build an R-tree index with the Rtree pacakge, which has some good examples in the documentation. With an R-tree index, you can use intersection to see where the bounding boxes intersect. This is similar to PostGIS' GiST index, except in my experience it is much faster to build and use. And if/when you need to do a detailed intersection of the geometries, you can use Shapely, which in turn uses GEOS, which is the same library used by PostGIS. So they are all related in similar ways.

See these related questions:

Community
  • 1
  • 1
Mike T
  • 41,085
  • 18
  • 152
  • 203
  • This is awesome, putting something together this afternoon. Do you have any suggestions for generating geometries like a bounding box or point radius – AlienAnarchist Apr 17 '14 at 19:55
  • It depends on what library you use to read the shapefiles. Each shape will have something like "bounds", "bbox", "extent", or "envelope" which you can use to build a spatial index with Rtree. – Mike T Apr 17 '14 at 20:07