I have a Garmin GPS that does handy things like waypoint averaging which is very useful in my situation where much of my data collection happens under heavy canopy in deep gullies which leads to inaccurate fixes. I often take several samples on different trips to get accurate positions.

The Garmin gpx files have a samples attribute in the extensions and I would like to be able to get this loaded into QGIS so I can have a script update the geometry if the sample number has changed.

here is a sample point with extension data

<wpt lat="-36.599535" lon="174.887440">
  <ele>2499999890505881600000000.000000</ele><time>2017-04-27T00:54:16Z</time><name>TJ B2 1</name>
  <cmt>Track junction in B2</cmt>
  <sym>Flag, Blue</sym>

to load the file I am using the "add GPX layer" -- the old gps tool.

the GPS exposes the files as a USB file system so I am just reading them as files. I can preprocess the files to, say put the sample data into the 'cmt' field but I would rather have a solution in QGIS because I want others to use this.


1 Answer 1


The "old" GPS tool does not seem to understand the extension tags, maybe it is too old for that.

Instead, use Add vector Layer, but there are still some pitfalls.

If I take a sample of my logger:

 <label xmlns="http://www.topografix.com/GPX/gpx_overlay/0/3">
   <label_text>Push Log Point #1</label_text>

I get a field named label with the content <label_text>Push Log Point #1</label_text> (including some trailing blanks).

With your example, I get a field wptx1:WaypointExtension with a content of 0.

Splitting the extension over several lines like


I get a field content of <wptx1:Samples>4</wptx1:Samples>

Removing the wptx1:WaypointExtension like this:


creates a field named wptx1_Samples with a content of 4 (which is probably what you want).

The manpage http://www.gdal.org/drv_gpx.html notes that extensions fields are taken from the first waypoint, so make sure all waypoints have the same extensions.

Alternatively, you can use the OSGEO4W Shell to convert a GPX file to a point shapefile on the command line with:

ogr2ogr --config GPX_USE_EXTENSION YES out1.shp sample1.gpx waypoints
  • Thanks Andre! I will almost certainly end up preprocessing my gpx files but it is really useful to know that 'add vector layer' can handle extension, even if it is a bit simple minded. I will try using that instead of the old GPSTOOL Commented May 1, 2017 at 20:30
  • You might as well take a look at stackoverflow.com/questions/18071387/… and stackoverflow.com/questions/36871829/… for programmatical solutions.
    – AndreJ
    Commented May 2, 2017 at 5:28
  • I have just found a "gotcha" with using "add vector layer" with GPX files. It creates 3D geometry and when I try and add these points into my PostGIS tables I get errors about the mismatched geometry. I also get errors when I if I save the files to spatialite telling it to ignore 'z' in the geometry option. Commented May 7, 2017 at 5:29
  • The ele value you privided does not make sense. It might help to use ogr2ogr with --config GPX_ELE_AS_25D NO.
    – AndreJ
    Commented May 7, 2017 at 5:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.