I'm trying to intersect large datasets in OGR and python using SQL queries like ST_Intersects
and ST_Contains
. These operations run very fast in ArcMap but I'm designing a system to automate them, hence using OGR and python. My code is taking forever to run (days). I've read recently that spatial indexing will help speed up these operations. I can generate these files by indexing the shapefiles in ArcMap, which generates .sbx and .sbn files. If those files accompany my .shp .dbf .shx and .prj files in the corresponding directories, will the speed of the operations benefit?
Alternatively, will the operation speed increase if the shapefiles are loaded in to a postGIS database instead of read in via the file system?