[gdal-dev] How to get the same behaviour as the 'Difference tool' of QGIS, in ogr2ogr?

Devdatta Tengshe devdatta at tengshe.in
Wed May 10 00:56:10 PDT 2023


I have a shapefile with lines, and another with polygons. I want to
generate an output of those lines that are not covered by any polygon.

I can perfectly do this in QGIS's Difference tool, but want to do it with
og2ogr. (since it will be a part of a cronjob)

I tried to do it, using the following command:
`ogr2ogr -overwrite out.shp line.shp -dialect SQLite -sql "select
st_difference(a.geometry, b.geometry) as geometry from line as a,
'polygon.shp'.polygon as b"`

But it just generated a .dbf file.

This behavior has also been reported here:
https://gis.stackexchange.com/a/324837/442

Is this a bug, or expected behavior? Is there a better way to achieve what
I want to?


Regards,
Devdatta
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20230510/8668e80b/attachment.htm>


More information about the gdal-dev mailing list