[gdal-dev] ogr2ogr intersect very slow at command line with large sqlite input

jratike80 jukka.rahkonen at maanmittauslaitos.fi
Sun Apr 9 13:02:19 PDT 2017

CTL101 wrote
> Hi Stephen, thanks for responding. Yes I do have spatial indexes as prior
> processing was filtering using ogr2ogr to select desired rows in the table
> for subsequent processing. It is my understanding that ogr2ogr defaults to
> producing these spatial indexes unless specifically instructed not to.


Spatialite does not have a real spatial index that generally just works
transparently. GDAL is clever enough for utilizing spatial index in trivial
cases like when ogr2ogr is used with the -spat option. However, I am pretty
sure that you must enhance your query with a hand written subquery that
select rowids from the virtual SpatialIndex. I guess it can be a bit tricky
and require some thinking and testing. I would follow the example from
https://www.gaia-gis.it/fossil/libspatialite/wiki?name=SpatialIndex and test
it with a simplified version of your query first.

-Jukka Rahkonen-

View this message in context: http://osgeo-org.1560.x6.nabble.com/ogr2ogr-intersect-very-slow-at-command-line-with-large-sqlite-input-tp5316545p5316555.html
Sent from the GDAL - Dev mailing list archive at Nabble.com.

More information about the gdal-dev mailing list