As my time at OSU and in Corvallis comes to a close, I figured it was a good idea to look back at what I got up to while I was there. I’ve always enjoyed tracking my running, biking, and hiking activities to see my own stats and provide bragging material. As a result, I had GPS tracks for most of my activities around town on my two favorite tracking apps: Strava and Gaia. I was inspired by this One Minute Map Hack from John Nelson to pull all this data together and visualize it in a way that allowed my favorite routes to light up and come to the forefront.
The unexpected challenges came in obtaining the data and getting it into a usable format.
Wrangling Strava data mounted the biggest challenge. Strava provides an option for you to download all the data attached to your account under Settings > My Account > Download or Delete Your Account in one massive zip folder. The ‘activities’ subfolder included in this download contains a combination of GPX, GPX.gz and FIT.gz files. To wrangle all this data into a format I could use easily in ArcGIS, I needed to:
- Extract the compressed .gz files
- Convert GPX point files to lines
- Merge all the discrete line files into a single feature class to import into Arc Pro
Unzip .gz Files
To convert .gpx.gz files to .gpx format, I installed 7-Zip and extracted the files. This can be done easily in bulk by selecting all the files in question in the Windows File Explorer or Mac OS equivalent.
Convert and Combine GPX files to a Single Feature Class
Now I had a pile of 70+ GPX files. ArcGIS Pro has a built-in tool to convert these to feature classes one-by-one, but I wasn’t too intent on clicking through a list of that many tracks for multiple steps to convert and combine them. To alleviate some of this pain, I wrote a quick python script using some arcpy package tools. The process primarily relies on four arcpy tools:
# Convert the GPX file into features arcpy.GPXtoFeatures_conversion(input_gpx_file, point_file_out_name) # Select only the track points arcpy.SelectLayerByAttribute_management(point_file_out_name, 'NEW_SELECTION', "\"Type\" = 'TRKPT'") # Convert the tracks into lines. The 'Name' field creates unique tracks. arcpy.PointsToLine_management(point_file_out_name, line_file_out_name, 'Name', '#', 'NO_CLOSE') # Merge all the tracks into one FC arcpy.Merge_management(list_of_line_files, FC_out_name)
The full code for the script can be found below, in .docx format due to WordPress file type restrictions. If you want the .py file directly, email me and I’ll send it your way!
Be aware of some filler variable names that you will need to replace with your own file paths. I’ve denoted them in the format: <description>.
At this point, the destination geodatabase I specified in the script had a single feature class containing a line feature for each GPX file passed to it.
Getting my hands on the Gaia track data was easy enough, albeit a little less obvious than I would have liked. In the Gaia GPS web portal, I added all of the tracks in question to a folder, went to that folder’s page, and then clicked the data download button, which gave options for GPX, KML, and GeoJSON formats. I downloaded the data in GeoJSON format and imported to ArcGIS Pro with built-in tools. This resulted in a single feature class with line objects for each track – perfect!
I blatantly copied this video for visualization technique, as I was happy with John Nelson’s work and the style worked great for my purposes: looking back on my data and showing off my activities to my friends.
I set the transparency of the line features to around 80-85%, but the best value for each case will vary based on the specific data set and what you’d like to make pop. I made the line weights fairly bulky, as GPS-based tracking data is pretty noisy at the scale shown, especially in a tree-or building-filled area like Corvallis. Again, the best value here will vary based on the data used and scale it’s shown at.
The only other layer in the map seen here is the ESRI World Dark Grey Canvas basemap.
As always – feel free to get in touch with any questions, comments, or concerns!