Takes a bunch of KML files generated by MyTracks and merges them into one.
This is a really janky, hacky script, but it does the job.
- In My Tracks, in the list of tracks, sync to GDrive.
- Download the GDrive
mytracks
folder.- Upload all new/original track files (so, non-merged, etc) to
mytracks_original
, to keep a backup
- Upload all new/original track files (so, non-merged, etc) to
- Copy the downloaded
mytracks
folder to this repo'smytracks
- Manipulate any files you may need to manipulate. (see section below)
- Use the visualizers below, plus this script's CLI arguments to generate the file you actually want.
- Read the code of
merge_all()
to understand what kind of things need to happen to a file you touch. - If you manually manipulate a track, upload it to
mytracks_original
with suffix-fixed
- If you'd originally renamed the track to call attention to it, rename it back to the standard Date
format in
mytracks_original
. - Leave the manipulated file in
mytracks
, with the correct track name (with date in it) so it'll be picked up in order and its date parsed on the merge step.
ruby merge.rb
to merge all the files in themytracks
folder into a new one.- Maybe include the previous merged, maybe not... You may end up with enormous files...
- Lots of the graphing tools have a 10 Mb limit, so mind that.
- Upload the
Merged...
generated file to GDrive inmytracks
- Move all non-"Merged" tracks from
mytracks
tomytracks_original
Getting the new merged track onto the phone:
- DO NOT go to Sync / Restore and "restore". It seems to re-restore old tracks that are no longer in
mytracks
somehow - On the list of tracks, delete all of them. This will be exceedingly painful.
- Kill the MyTracks app
- Open the Drive app
- Choose the Merged tracks to copy to the phone and
Download
.- NOTE: In the past, I had trouble with the "downloaded" file, it wouldn't import, MyTracks would just crash.
- I made a note at the time to hit
Copy to
, (notDownload
!). - That option no longer seems to be there, though, and importing after
Download
seems to work now...
- Go to list of tracks, menu on the top, Import, and select the files to import in the
Downloads
folder.- Once the track imports, leave it alone!. Don't change it to Cycling, or anythign else, or MyTracks sometimes does weird shit like double the distance.
- On "Tracks & Markers", delete all the markers. They can all be selected and deleted at once.
Alternatively, and especially if My Tracks is being stupid:
- Go to "App info", and clear all Cache and Stored data
- Import the merged tracks again
- Go to "No ads" on the menu, so it'll realize i've already paid.
- Settings:
- General: Turn off everything
- Track & Marker:
- Width of route: 6
- Auto save a route when stopped: Yes
- Photos shown: No
- Max speed should be less than: 60
All of these are commands are run with ruby merge.rb command [options]
, act on one single file specified with
the -f
parameter, and generate an output.kml
in the root directory with the results.
- Slice a file: Reduce the route in a file to only points that fall between the two specified timestamps
ruby merge.rb slice -f "mytracks/Route from 2020-07-23 11_39.kml" --from "2020-07-23 13:14:47" --to "2020-07-23 14:00:10"
- Split a file: Split a route into two, with the points before/after the
--at
parameters. Outputsoutput_before.kml
andoutput_after.kml
.ruby merge.rb split -f "mytracks/Route from 2020-07-23 11_39.kml" --at "2020-07-23 14:00:10"
- NOTE: If you get error
merge.rb:153:in 'split': undefined method '>' for nil:NilClass (NoMethodError)
, you entered a time that's not in the time range for the route. Either before the start or after the end.
- Retime a file: "Move" the times in a route, keeping the length/speed the same, so it starts at a new point in time.
ruby merge.rb retime -f "mytracks/Route from 2020-07-23 11_39.kml" --start "2020-07-24T10:39:49.537Z"
- Compress time on a file: Change the length/speed of a route, so it starts at the same time, but ends at a new point in time.
ruby merge.rb compress_time -f "mytracks/Route from 2020-07-23 11_39.kml" --end "2020-07-23T17:20:49.537Z"
- Compact time on a file: eliminates time gaps between rides, so it's all one non-stop continuous ride.
Useful to calculate actual average speed and riding time.
- `ruby merge.rb compact_time -f "mytracks/Route from 2020-07-23 11_39.kml"
- These files won't import into My Tracks, for some stupid reason. GPS Visualizer has a "Show track statistics" option in "advanced leaflet" which will show total distance and total time.
- Online KML Viewer: Useful to just see a route
- Another Online KML Viewer: Useful to see individual points
- Go into "advanced leaflet options"
- Enter "1 min" into
Tickmark interval