3

I have a GPX file containing trackpoints, similiar to the following:

<trkpt lat="12.34567890" lon="-12.34567890">
        <ele>250.100000</ele>
        <time>2016-06-03T13:09:47Z</time>
        <course>140.300003</course>
        <speed>15.639112</speed>
        <geoidheight>-34.6</geoidheight>
        <fix>3d</fix>
        <sat>5</sat>
        <hdop>2.800000</hdop>
        <vdop>1.600000</vdop>
        <pdop>4.600000</pdop>
</trkpt>

How do I convert the GPX file to a SHP file and include all the extended fields, like hdop, vdop, pdop, etc.? This will eventually be imported into GIS software like QGIS or ArcMap but I prefer SHP over a database for portability.

I tried using OGR2OGR with -dsco GPX_USE_EXTENSIONS=YES but that doesn't bring the extended properties along to the SHP file.

I prefer a command line approach to doing this. I will be trying to automate the process.

DenaliHardtail
  • 3,177
  • 4
  • 34
  • 68

2 Answers2

1

GPSBabel is my go-to for this (unless you have access to FME).

DNRGPS is another option. I prefer GPSBabel just because I've been using it for longer.

If you have ArcMap, see this other post for ArcMap specific answers: What is the simplest method to add GPX files into Arcmap?

MaryBeth
  • 3,694
  • 24
  • 41
1

if you don't mind a manual, mousing-around process in QGIS, try this:

  1. click the Add Vector Layer button, select 'File' as the Source type, and browse to your GPX. This adds layer(s) from your GPX to the map.
  2. in the Layers Panel, right-click the desired layer and select Save As...
  3. in the resulting dialog select 'ESRI Shapefile' as the Format

To test the above, I hacked together the following from your single track point, and the attribute columns did come across into the resulting shapefile (among others added by QGIS). Hope it works for you too.

<?xml version="1.0" ?>
<gpx xmlns="http://www.topografix.com/GPX/1/1">
 <trk>
  <name>
   Century Loop
  </name>
  <trkseg>
<trkpt lat="12.34567890" lon="-12.34567890">
        <ele>250.100000</ele>
        <time>2016-06-03T13:09:47Z</time>
        <course>140.300003</course>
        <speed>15.639112</speed>
        <geoidheight>-34.6</geoidheight>
        <fix>3d</fix>
        <sat>5</sat>
        <hdop>2.800000</hdop>
        <vdop>1.600000</vdop>
        <pdop>4.600000</pdop>
</trkpt>  
  </trkseg>
 </trk>
</gpx>
MC5
  • 1,901
  • 1
  • 14
  • 23