12/10/2018 - 2:31 AM

Add GPX features to a GeoPackage

Add features from several GPX files in a directory to a GeoPackage

This is motivated by the fact that Runkeeper exports all your GPS data to individual GPX files. These GPX files contain 5 different tables:

  1. route_points
  2. routes
  3. track_points
  4. tracks
  5. waypoints

track_points and tracks seem to be the only tables that ever contain features and are the ones I'm most interested in. What would be really nice is to have all the individual GPX files merged into a single GeoPackage. We can do this with ogr2ogr


I downloaded all my data from Runkeeper. This comes in a zipped directory. I unzipped the directory and was left with a folder of each individual GPX file. There were also a couple CSV files with additional data, but dealing with those is not really important here.

In the directory with all my GPX files I created a new directory called output using the commmand line:

mkdir output

I then cut and pasted the first GPX file into the output directory. I opened up the OSGEO4W shell in my data directory and ran the following command:

ogr2ogr -f GPKG output/name_of_file.gpx output/rides.gpkg

This created a new Geopackage, output/rides.gpkg, with tables containing features from that one GPX file added to the output file. I have hundreds of these. They need to be added to output/rides.gpkg. So for that, I ran the following:

for %f (*.gpkg) do ogr2ogr -update -append -f GPKG %f output/rides.gpkg

It took a while, but in the end, all the GPX files were added to a single GeoPackage!