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"> <name>foo</name> <extensions> <ogr:sample>bar</ogr:sample> <ogr:lat>1.23456</ogr:lat> <ogr:lon>7.890123</ogr:lon> </extensions> </wpt> </gpx>
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) OGRFeature(waypoints):0 name (String) = foo ogr_sample (String) = bar ogr_lat (Real) = 1.23456 ogr_lon (Real) = 7.890123 POINT (1.23456 7.890123)