[gdal-dev] ogr2ogr and RFC41
Even Rouault
even.rouault at spatialys.com
Thu Oct 23 16:16:31 PDT 2014
Le jeudi 23 octobre 2014 22:49:17, Martin Landa a écrit :
> Hi,
>
> 2014-06-11 23:45 GMT+02:00 Even Rouault <even.rouault at mines-paris.org>:
> > Yes, by default it will transfer all source geometry fields into the
> > target layer, if it supports multiple geometry fields. If you want only
> > a subset of source geometry fields, you can write a SQL clause " SELECT
> > geomfield1, geomfield2, other_attr FROM your_layer"
>
> it's not work for me, eg.
>
> $ ogr2ogr -f GPKG -sql "select originalnihranice from staty"
> staty.gpkg PG:dbname=vfr_uksh_10_cr -overwrite
>
> gives
>
> $ ogrinfo staty.gpkg sql_statement | grep Geometry
>
> Geometry: Unknown (any)
> Geometry Column = geom
It works. It is just that it cannot guess the geometry type from a SQL that
could potentially return arbitrary geometries (well we could perhaps add
heuristics to detect that the column is indeed a column of a spatial table,
similarly to what exists in the spatialite&gpkg driver) . You can however
specify -nlt multipolygon if you want stronger typing
>
> I found `-select` option which seems to work:
>
> $ ogr2ogr -f GPKG -select originalnihranice staty.gpkg
> PG:dbname=vfr_uksh_10_cr staty -overwrite
>
> $ ogrinfo staty.gpkg staty | grep Geometry
>
> Geometry: Multi Polygon <-- OK
> Geometry Column = geom
Yes because here we know that we are directly extracting information from the
source layer.
>
> But it's still no usable, having attribute table with 10+ attributes I
> need to write something like
>
> --select geom2,attr1,attr2,...attr10
>
> Would make sense to you to add a new option
>
> --except geom1
>
> or
>
> --select !geom1
The later kind of reminds me of MapServer syntax :
"wms_enable_request" "* !GetFeatureInfo"
So perhaps something like ?
--select *,!geom1,!attr1
I can be wrong but there's no SQL syntax for "* but X and Y", is there ?
>
> ?
>
> Thanks, Martin
--
Spatialys - Geospatial professional services
http://www.spatialys.com
More information about the gdal-dev
mailing list