[gdal-dev] ogr2ogr SQL command

Rousseau Lambert2, Louis-Philippe (EC) louis-philippe.rousseaulambert2 at canada.ca
Fri Jun 29 05:48:39 PDT 2018


Hi Even, 

Thanks for the quick answer.

I tried with your example test.csv, and for me it really doesn't work with 2.2.2... There is simply nothing as output. 

I tried with the older version 1.10 and it works fine. 

I'll simply have to upgrade to 2.2.4 I guess.

Thanks

LP
________________________________________
De : Even Rouault <even.rouault at spatialys.com>
Envoyé : 29 juin 2018 08:34
À : gdal-dev at lists.osgeo.org
Cc : Rousseau Lambert2, Louis-Philippe (EC)
Objet : Re: [gdal-dev] ogr2ogr SQL command

On vendredi 29 juin 2018 12:12:06 CEST Rousseau Lambert2, Louis-Philippe (EC)
wrote:
> Hi,
>
>
> I was trying to dissolve some buffers based on a attribute in a shapefile
> and faced something weird.
>
>
> I do the dissolve with ogr2ogr command line:
>
> ogr2ogr coverage_dissolve.shp coverage.shp -dialect sqlite -sql "SELECT
> ST_Union(geometry), type FROM coverage GROUP BY type"
>
>
> This works fine with GDAL 1.10.0, but when I try to do the same thing with
> GDAL 2.2.2, nothing happens...
>
>
> Is there a another way of doing SQL commands in gdal 2.2.2 or am I missing
> something else?

Works fine for me with 2.2.4 and later with the following trivial dataset:

Given test.csv:
id,type,WKT
1,"x","POLYGON((0 0,0 1,1 1,1 0))"
2,"x","POLYGON((0 0,1 0,1 1,1 0))"

$ ogr2ogr coverage.shp test.csv
$ ogr2ogr coverage_dissolve.shp coverage.shp -dialect sqlite \
  -sql "SELECT ST_Union(geometry), type FROM coverage GROUP BY type"
$ ogrinfo coverage_dissolve.shp -al -q
[...]
OGRFeature(coverage_dissolve):0
  type (String) = x
  POLYGON ((0 0,0 1,1 1,1 0,0 0))

Perhaps there was also a change in Spatialite and GEOS versions when upgrading
from GDAL 1.10 to 2.2.2 ? Are all your geometries valid ?

Even

--
Spatialys - Geospatial professional services
http://www.spatialys.com


More information about the gdal-dev mailing list