[gdal-dev] Selecting just the geometry column with OGR SQL

Rahkonen Jukka (MML) jukka.rahkonen at maanmittauslaitos.fi
Mon Nov 9 05:25:06 PST 2020


Hi,

I believe that OGR SQL dialect adds the geometry column into SQL selection by default. Am I right with this? I volunteer to edit the documentation https://gdal.org/user/ogr_sql_dialect.html if this is the case. But what I can't understand is another side of the story, how to select just the geometry field with OGR SQL dialect from some data sources.

This command returns both time column and geometry from GML
ogrinfo -sql "select time from timetest" timetest.gml
I can select just the geometry from geometry column named as "geometryProperty" by
ogrinfo -sql "select geometryProperty from timetest" timetest.gml

The behavior is the same with SpatiaLite when I use "-dialect OGRSQL". Geometry is selected automatically but it can be selected also by name. But I cannot discover any way to select just the geometry field from shapefile. Is it because geometry column in shapefile does not have any name as this Python test seems to prove?

>>> from osgeo import ogr
>>> shp_ds = ogr.Open('timetest.shp')
>>> shp_lyr = shp_ds.GetLayer(0)
>>> shp_lyr.GetGeometryColumn()
''

OpenJUMP JML driver does not report a name for geometry column either. Is it rather an exception that drivers give names for the geometry columns? I know I can select only the geometry column with the SQLite dialect, but I am curious.

-Jukka Rahkonen-






-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20201109/44a0429b/attachment.html>


More information about the gdal-dev mailing list