[gdal-dev] "dialect SQLITE" isn't working as expected in ogr2ogr

Even Rouault even.rouault at spatialys.com
Wed Oct 26 03:51:56 PDT 2016


Le mercredi 26 octobre 2016 12:47:28, Nelson A. de Oliveira a écrit :
> Hi!
> 
> I can't get a proper output when using "-dialect SQLITE" with ogr2ogr
> 
> For example, this properly works:
> 
> =====
> ogr2ogr -update -append -f "ESRI Shapefile" -sql "SELECT NM_TIPO_LO,
> NM_TITULO_, NM_NOME_LO FROM \"35032080500_face\"" -t_srs EPSG:4326
> merged.shp 35032080500_face.shp
> =====
> 
> I can see 4 files, as expected:
> merged.dbf, merged.prj, merged.shp and merged.shx
> 
> 
> Adding "-dialect SQLITE" (remove the merged* files before running):
> 
> =====
> ogr2ogr -update -append -f "ESRI Shapefile" -dialect SQLITE -sql "SELECT
> NM_TIPO_LO, NM_TITULO_, NM_NOME_LO FROM \"35032080500_face\"" -t_srs
> EPSG:4326 merged.shp 35032080500_face.shp
> =====
> 
> This is only a simpfilied example, as I would like to use some SQLITE
> functions that aren't available in OGR SQL, for example.
> 
> The problem is: ogr2ogr doesn't give any warning or error message, but
> I can see only two files being created: merged.dbf and merged.prj

Yes, you didn't explicitly select the geometry field, hence a geometry-less DBF 
is produced. This is indeed a difference in behaviour between OGR SQL (where 
geometry selection is implicit) and the SQLite dialect (where it must be 
explicit, conforming to other spatial enabled SQL databases).

See the "Geometry field" section in http://www.gdal.org/ogr_sql_sqlite.html

Even

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


More information about the gdal-dev mailing list