Obtaining the Data
The first thing you need is the GPS data to be merged. While Strava has a built-in export command, the data that it will export will be in GPX (GPS Exchange) format. While GPX is an open standard, it has been extended by several manufactures to include customized data. Thus when exporting a ride using GPX some data, such as Heart Rate information, can be lost. The alternative is to export the data using the TCX (Garmin Training Center XML) file format. In order to export the data using TCX format, you have to use a hidden feature on Strava. Instead of using the export button, you add "/export_tcx" to the end of the URL string for your ride. After you hit enter the ride data in TCX format will be saved to your local downloads directory. As a general rule, you will need to download all activities in the same format.
If you upload your rides to Garmin Connect, you can also easily export them in TCX format. In both their Modern and Classic modes, there is an export button with multiple options available. Once you select TCX the activity download will start.
Classic Interface | Modern Interface |
Once you have downloaded the activities you wish to merge, you need a text editor. Because both GPX and TCX files are in a standardized text format (XML), it is relatively easy to find the sections that you are looking for. TCX files are a little easier to read than GPX files, but they both have a similar layout. For those that have done much HTML design, XML markings should look familiar. What you are looking for is the starting section for event. In TCX files this is the <Lap ...> tag. For GPX files you are looking for the <trkseg> tag. At the end of the file should be a corresponding closing tag ( </Lap> for TCX, </trkseg> for GPX) that marks the end of the event. The information between the opening tag and closing tag is your actual activity data, so be careful to not delete or change the format of that section of the file.
To merge the two activities copy everything between the event segments, including the opening tag and closing tag, from the later of the two activities to the earlier of the two activities. You should be pasting the newer data at the bottom, in between the closing tag of the original activity (</Lap> for TCX, </trkseg> for GPX) and the closing of the activity itself ( </Activity> for TCX, < /trk> for GPX). After pasting the second activity into the first save the file as a new name (typically File, Save As), remembering the name and location.
Select everything between |
Save As a new filename, using the same .tcx extension |
Uploading the Results
Once the new file is created, it is time to upload the combined data. In Strava, there is an option to upload files as well as importing directly from your chosen fitness device. Once you click the upload button, select File from the left menu. From there you can choose the new combined file.
The new file will now upload. If you are replacing a previously uploaded activity, you may get an error saying that your activity is a duplicate, specifically of the earlier of the two activities. It should be best practice to delete the original activities, if previously uploaded, from your feed.
Errata
Since the end result is two files that are merged together, there may be some errata. This should be expected, as the data set is most likely not complete. The most common issue is that you are going to have a straight line that connects the end of the first activity to the beginning of the second. Currently Strava will also add this distance into your total as the crow flies, and take the timestamp difference between the two activities and use it for your average speeds. If there is a large difference in location and/or time, it may create a rather large amount of data error.
Data Errata |
For the rare time times that I have ended up with data issues that have resulted in multiple activity files, this method has shown to be useful. For those that track data using device files and fitness sites, having a method to accurately display fitness data is helpful.
No comments:
Post a Comment