[gdal-dev] ogr2ogr and GPX files

Even Rouault even.rouault at mines-paris.org
Mon Mar 3 14:42:12 EST 2008


In fact, using the same principle, you can use just one command line and no 
intermediary file :

ogr2ogr -f GPX destination.gpx source.shp -sql "SELECT  src_field_1 AS name, 
src_field_2 AS desc FROM your_source_layer_name"

Thanks to FrankW for the tip ;-)

Le Monday 03 March 2008 19:43:12 Even Rouault, vous avez écrit :
> Hi,
>
> I see your point...
>
> The solution is the powerful OGR Virtual Dataset format !
> See http://www.gdal.org/ogr/drv_vrt.html
>
> In fact, the documentation should probably be extended to demonstrate the
> power of the OGR SQL for that particular case
>
> Try to paste the following lines in a file (remapped_layer.vrt would be
> fine)
>
> <OGRVRTDataSource>
>     <OGRVRTLayer name="remapped_layer">
>         <SrcDataSource>your_source.shp</SrcDataSource>
>         <SrcSQL>SELECT src_field_1 AS name, src_field_2 AS desc FROM
> your_source_layer_name</SrcSQL>
>     </OGRVRTLayer>
> </OGRVRTDataSource>
>
> Replace your_source.shp, src_field_1, src_field_2 and
> your_source_layer_name by the appropriate values from your source dataset
> and 'ogrinfo -ro -al remapped_layer.vrt' should show a structure compatible
> of a GPX file.
>
> Best regards,
> Even
>
> Le Monday 03 March 2008 07:04:41 Dylan Beaudette, vous avez écrit :
> > Hi,
> >
> > is there a simple approach (via ogr2ogr) to create GPS files which have
> > standard waypoint tags such as <name>, <elev>, <cmt>, etc. by re-mapping
> > columns in the attribute table of the source vector?
> >
> > for example:
> >
> > # export points vector from GRASS
> > v.out.ogr in=wp type=point dsn=wp.shp
> >
> > # convert tp GPX:
> > ogr2ogr -t_srs '+proj=latlong +datum=WGS84' \
> > -f GPX -dsco GPX_USE_EXTENSIONS=YES \
> > wp_gps.gpx wp.shp
> >
> > This results in a working GPX waypoints file, that when uploaded to a GPS
> > is functional, but the waypoints are all re-named sequentially. Note that
> > I am uploading the GPX file the GPS via gpsbabel.
> >
> > Does anyone know of the appropriate incantation that one could use to
> > translate the column structure of the input wp.shp (i.e. the stuff in
> > its .dbf) into standard waypoint tags?
> >
> > thanks in advance!
> >
> > PS: trying to write a simple tutorial for some colleagues [1]
> >
> > 1. http://casoilresource.lawr.ucdavis.edu/drupal/node/553
>
> _______________________________________________
> gdal-dev mailing list
> gdal-dev at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/gdal-dev




More information about the gdal-dev mailing list