I am currently planning a marine science expedition and need to convert some points from a .shp to a GPX for display in OpenCPN (chartplotting software) while retaining an extra field or two. I swear I got this to work a few years ago when I tried. I even wrote down some documentation to go back to (which does not appear to work anymore).

Currently, I have a set of points in a shapefile, it has "Name" (Text), "Sample" (Text), Lat (double), Long(double).

I had typically used QGIS to export the shapefile (save as) GPX. I have made sure that GPX_USE_EXTENSIONS = YES, which I could have sworn was what allowed the additional fields to export along with the name.

Unfortunately no matter what I do, when I import the GPX into OpenCPN I only get the "Name," but no "Sample" field.

Any ideas?

  • If you add the gpx back into QGIS does it have the extra field? Does some other software, such as the free DNR Garmin/DNR GPS, see the extra field in the gpx? Can they save the shapefile as a gpx that OpenCPN shows both fields?
    – John
    Feb 23, 2023 at 23:48
  • Added it back into QGIS and it has "ogr_Biosample, ogr_Lat, ogr_Long" all retained at the end of the attribute table. So I think you are correct that it must be a software issue on the OpenCPN side of things.
    – Szechwan
    Feb 27, 2023 at 17:41

1 Answer 1


Seems to work for me. I made a test with GDAL 3.7.0dev and this GeoJSON file

"type": "FeatureCollection",
"features": [
{ "type": "Feature", "properties": { "name":"foo", "sample":"bar", "lat":1.23456, "lon":7.890123 }, "geometry": {"type":"Point","coordinates":[1.23456,7.890123]} }

and with this command

ogr2ogr -f gpx -dsco GPX_USE_EXTENSIONS=YES gpxtest.gpx gpxtest.json

and the result is:

<?xml version="1.0"?>
<gpx version="1.1" creator="GDAL 3.7.0dev-5ce7ba068f" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ogr="http://osgeo.org/gdal" 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="7.890123000000000" minlon="1.234560000000000" maxlat="7.890123000000000" maxlon="1.234560000000000"/></metadata>                      
<wpt lat="7.890123" lon="1.23456">

Now ogrinfo shows this:

ogrinfo gpxtest3.gpx waypoints

INFO: Open of `gpxtest3.gpx'
      using driver `GPX' successful.

Layer name: waypoints
Geometry: Point
Feature Count: 1
Extent: (1.234560, 7.890123) - (1.234560, 7.890123)
Layer SRS WKT:
Data axis to CRS axis mapping: 2,1
ele: Real (0.0)
time: DateTime (0.0)
magvar: Real (0.0)
geoidheight: Real (0.0)
name: String (0.0)
cmt: String (0.0)
desc: String (0.0)
src: String (0.0)
link1_href: String (0.0)
link1_text: String (0.0)
link1_type: String (0.0)
link2_href: String (0.0)
link2_text: String (0.0)
link2_type: String (0.0)
sym: String (0.0)
type: String (0.0)
fix: String (0.0)
sat: Integer (0.0)
hdop: Real (0.0)
vdop: Real (0.0)
pdop: Real (0.0)
ageofdgpsdata: Real (0.0)
dgpsid: Integer (0.0)
ogr_sample: String (0.0)
ogr_lat: Real (0.0)
ogr_lon: Real (0.0)
  name (String) = foo
  ogr_sample (String) = bar
  ogr_lat (Real) = 1.23456
  ogr_lon (Real) = 7.890123
  POINT (1.23456 7.890123)

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.