37

I would like to convert .shp into .gpx.

Using GIS, I open my shapefile and I tried to "save as" gpx but it gives an OGR error:

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

How can I fix this error?

2
  • I tried this in another PC with the same OS and it works! Andre Joost is correct! I still dont know why this works here and doesn't work in the other PC. Should i install GPX driver?? :| Thanks André Joost!
    – ePascoal
    Commented Nov 12, 2012 at 9:16
  • in a situation like that, where the error mentions a parameter or setting you're not familiar with, check the related GDAL or OGR formats page for the driver you're using, e.g. GPX. In some scenarios, you won't want to blindly apply an option as it might hurt your data. Case-in-point, you would not want to indiscriminantly apply -skipfailures in ogr2ogr without researching why it's failing in the first place.
    – elrobis
    Commented Dec 6, 2012 at 17:18

6 Answers 6

36

Just do what you are told: In the Data source field, enter

GPX_USE_EXTENSIONS=YES

or check "skip attribute creation" underneath (or what it is named in your language).

In the Layer field, you might also enter

FORCE_GPX_TRACK=YES

to get tracks instead of routes.

6
  • Thanks, it really works, but when i convert shp to gpx i lost my Id field. All my gpx fields are null. How can i correspond my "id" field(shp file) to "name" field(gpx file).
    – ePascoal
    Commented Nov 9, 2012 at 14:26
  • 5
    I'm afraid this is not possible on exporting. it is possible with ogr2ogr.exe from the gdal package: ogr2ogr -f GPX -dsco GPX_USE_EXTENSIONS=NO shpexport.gpx D:\path\to\your\test.shp -lco FORCE_GPX_TRACK=YES -sql "SELECT id AS name FROM layername"
    – AndreJ
    Commented Nov 9, 2012 at 15:55
  • 2
    You can use the table manager plugin to rename the id field in the shapefile to "name" before exporting and change it back afterwards. If necessary, you have to add pyqgis.org/repo/contributed to the list of your repositories.
    – AndreJ
    Commented Nov 10, 2012 at 6:15
  • 1
    i tried to rename the id field in shapefile to name before exporting but doesn't work. i look for an application that add an python app named PostGPS, but doesn't work. I tried with ogr2ogr using your script too without success :/ Am i doing something wrong. There is any other possible sollution?
    – ePascoal
    Commented Nov 11, 2012 at 19:45
  • Strange, it worked here. You have to set "GPX_USE_EXTENSIONS=YES" in the upper field of the Save As dialogue. With the checkbox it does not work. For the ogr2ogr, you have to use the layername, not necessary the same as the shapefiles name.
    – AndreJ
    Commented Nov 11, 2012 at 20:36
2

Alternatively, you can try the following steps:

  1. Open your SHP file with QGIS
  2. Select your SHP layer
  3. Layer > Save as... > GPX
2

One simple trick worked for us. In the main csv file, the first field (ID/ label) should be named 'name'. and then import that file and save as .gpx

1
  • Thanks for this - for any lurkers, this is the answer to get your pesky .gpx points to be named what you want!
    – sleepy
    Commented Apr 27, 2021 at 1:01
2

You can force:

GPX_USE_EXTENSIONS=YES

As indicated above. However, if you don't understand or manage your projections, then you will run into additional problems. You will find errors in the data - imprecision in the points or tracks if your CRS is different from what your shapefiles are projected in or how your workspace is projected; WGS84 is needed for GPS units.

The best solution I have found is to select "Reproject layer" from your processing toolbox. This gives you the option to batch convert multiple layers, reproject the data properly, and save as a gpx file.Reproject layer into gpx

The only issue that I haven't learned to solve is how to retain the labels. I'm hoping that someone might know how or have a trick to do this - it doesn't seem to be an option. I have had to either use the clunky Garmin BaseCamp software to click and revise the labels individually or go into the gpx code and type in the code manually - both are time consuming.

0

You can also use DNRGarmin from the Minnisota department of Natural Resources. It's a free tool and allows you to do a lot of imports and exports for GPS data

0

This worked for me:

  • Delete everything in Attribute Table
  • Keep it clean
  • Then export it

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.