[gdal-dev] Fwd: ogr2ogr. SQL seems to disable use_gpx_extensions

Even Rouault even.rouault at spatialys.com
Fri Sep 12 01:22:40 PDT 2014


Selon Pedro Machado Monteiro <pedromachadomonteiro at gmail.com>:

> Hello:
>
>
>
> I’m trying to export a shapefile to a GPX file, with GDAL 1.9.0 ogr2ogr.
>
>
>
> From the shapefile attribute table, I want  to export some fields to  the
> corresponding tags of the GPX file, and the remaining (or all) fields to
> the <extensions> tag
>
>
>
> That does’nt seem to work: when I use the *–sql* option SELECT AS (ex: to
> export the field “Linha” from the shape attribute table, to the GPX
> <name>), it seems that the *-dsco* option USE_GPX_EXTENSIONS=YES is
> disabled, because the result always lacks the <extensions> tag, with the
> remaining (or all) fields.
>
>
> But http://gdal.org/drv_gpx.html says that If GPX_USE_EXTENSIONS=YES is
> specified, extra fields will be written inside the*<extensions>* tag.
>
>
>
> Here is the kind of statement:
>
>
>
> *ogr2ogr* *-f* GPX *-dsco* GPX_USE_EXTENSIONS=YES exportfile.gpx
> sourcefile.shp
> *-sql* *"*SELECT Linha AS name FROM sourcefile*"*

Pedro,

The above SQL statement only selects one single field from the shapefile, so it
is expected that the resulting GPX will have only the standard <name> attribute.
You must explicitely list other fields in the SELECT clause if you want them to
go in <extensions>.
If you want to be quick and don't mind the Linha field to be in the extensions
as well in addition to <name>, you can just do "SELECT Linha AS name, * FROM
sourcefile"

Best regards,

Even


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


More information about the gdal-dev mailing list