QGIS – How to Export a Linestring to a GPX File

exportgpxlinestringqgis

I have a linestring in a vector layer in QGIS. How can I expot/save this linestring as a GPX file?

I tried to select the linestring, then right click on the vector layer and choose "Save selection as…" and then I choosed GPX format and saved it. But I got this error message:

Export to vector file failed.
Error: creation of field code_06 failed (OGR error: Field of name 'code_06' is not supported in GPX schema. Use GPX_USE_EXTENSIONS creation option to allow use of the element.)

The GPX file is created, but it contains no coordinates. Is there any settings I should do to avoid this error?

How can I export a linestring to a GPX file in QGIS?

Best Answer

The GPX format does support only a defined list of attributes, so if your vector has any attribute that does not match what the specifications say, you'll get that error.

When you export a vector to a gpx don't expect to have necessarily attributes with the coordinates, nevertheless they are present in the gpx file, example (obtained with QGIS):

<?xml version="1.0"?>
<gpx version="1.1" creator="GDAL 1.7.3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.topografix.com/GPX/1/1" xsi:schemaLocation="http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd">
<metadata><bounds minlat="-0.406488549618321" minlon="-1.158778625954199" maxlat="0.674427480916031" maxlon="1.520610687022901"/></metadata>                    
<rte>
  <name>um</name>
  <rtept lat="0.660687022900763" lon="-1.158778625954199">
  </rtept>
  <rtept lat="0.674427480916031" lon="-0.409923664122138">
  </rtept>
  <rtept lat="-0.001145038167939" lon="-0.041221374045802">
  </rtept>
  <rtept lat="-0.406488549618321" lon="0.453435114503817">
  </rtept>
  <rtept lat="0.239312977099237" lon="1.520610687022901">
  </rtept>
</rte>
</gpx>

More:

http://www.gdal.org/ogr/drv_gpx.html

Related Question