[GIS] QGIS: How to get Symbols saved in GPX Files

gpxqgisxml

I have some waypoint layers that contain different types of points and I distinguish these in QGIS by different symbols and colours. I want to export these to a GPX file that I can download to my GPS but The GPX file contains just the lat, long and the 'type'.

Is there a way of getting gpstool to save other attributes in a gpx file?

I do get some more data out in (gid, source and classification) so I can write a script to process the xml and add the necessary attributes that the GPS expects.

Secondary question: Would this make a useful plugin?

Best Answer

Using pure GDAL, you can preserve the waypoint symbol and type of an original GPX file with

ogr2ogr -f GPX -dsco GPX_USE_EXTENSIONS=YES out.gpx in.gpx waypoints

<wpt lat="51.295094" lon="6.790674">
  <ele>39.0</ele>
  <time>2014-10-14T13:56:58Z</time>
  <name>Push Log Point #1</name>
  <desc>Lat.=51.295094, Long.=6.790674, Alt.=39.000000m, Speed=3Km/h, Course=45deg.</desc>
  <sym>Waypoint</sym>
  <type>Other</type>
  <extensions>
    <label><label_text>Push Log Point #1</label_text></label>
  </extensions>
</wpt>

So if you have a shapefile in QGIS, create columns with names sym and type and export it to GPX format with GPX_USE_EXTENSIONS=YES (which is default for GPX since QGIS 2.4).

Remember to save into EPSG:4326, as GPX only allows that.

Other features (like label) will be exported in the <extensions> element, and probably ignored by a GPS unit. My output reads as follows:

<wpt lat="51.295094" lon="6.790674">
  <name>Push Log Point #1</name>
  <sym>Waypoint</sym>
  <type>Other</type>
  <extensions>
    <ogr:elevation>39.0</ogr:elevation>
    <ogr:label>1</ogr:label>
  </extensions>
</wpt>
<wpt lat="51.295091" lon="6.790663">
  <name>Push Log Point #2</name>
  <sym>church</sym>
  <type>tower</type>
  <extensions>
    <ogr:elevation>38.0</ogr:elevation>
    <ogr:label>2</ogr:label>
  </extensions>
</wpt>

The available symbols depend on the GPS units, so you might create a sample GPX file with the unit and test all available symbols. These will not be imported into QGIS, but you can read the file with a text editor.

As an example, symbols of the Garmin Oregon 6xx are listed at this site. You can even create your own symbols and upload them.