[GIS] Using ST_Intersects in OGR2OGR

gdalogr2ogr

I'm running GDAL 1.11.2, released 2015/02/10.

The following displays all the attributes in my shapefile on stdout:

/opt/gdal-custom/bin/ogr2ogr -f CSV /vsistdout/ foo.shp -sql "SELECT * FROM foo "

However, if I add the WHERE clause WHERE ST_Intersects(GEOMETRY,BuildCircleMbr(0, 0, 10000, 4326)) I get ERROR 1: Undefined function 'ST_Intersects' used.

What am I doing wrong?

Best Answer

Without knowing your dataset I can't be 100% sure, but I'd wager you can solve this by adding -dialect sqlite since ST_Intersects is a Spatialite SQL function.

Your command should be

/opt/gdal-custom/bin/ogr2ogr -f CSV /vsistdout/ foo.shp -dialect sqlite -sql "SELECT * FROM foo "
Related Question