In the previous article I presented how to import Sports GPX data into ArcGIS for Desktop (example taken with Runtastic). I did the exercise for a single GPX file but what do you do if you have several favorite tracks circuits? After having downloaded your routes, the import of hundred of GPX files by doing it manually through the ArcMap interface would take ages!!!
Simple solution: using a Python script!
Here is the little standalone script (= which does not require ArcMap to be open) that
- takes all the gpx files from a unique folder
- convert it into features placed in the specified geodatabase
- convert the feature layer into .lyr files
- style them
I saved this script naturally under the name gpx2features.py (GRAB IT FROM HERE!) and it splits into two parts:
- First step, at the bottom of the file, which defines the variables
- the folder containing the gpx files
- the output gdb where the converted gpx will be placed
- the path to reference layer for the symbology (Please the one that I used here: the lyr and the lpk (please unpack it before use))
- the output folder for the final lyr files
- the call to the main function convertGPX2feature
- Second step contents
- an array called “files”, which is filled with the path to all the gpx files, is put in a ‘for’ loop and each item is used in the GPXtoFeatures_conversion tool.
- A little “partition” has been applied to keep the feature names not as long as the original data
Of course, this script assumes all the gpx files are in the same folder. The script has to be adapted if they are in different folders.
Spot the circuits on the map
The steps afterwards are styling the map by choosing a nice layout and by adding the necessary cartographic information in order to show on a map your favourite tracks.
This is one example of a presentation but there are many others.