Recorded gpx tracks (from e.g. bicycle tours) are generally quite large, containing too detailed route information or details which are not needed for just displaying the route. Furthermore uploading individual tracks to google mymaps and styling them individually is quite tiresome. kml-routemap.ipynb demonstrates the automated kml map generation from recorded tours, including a defined layer styling:
- routes are simplified for file size reduction (google mymaps allows the upload of max. 5 MB, for me this script shrinked 92 routes of 169 MB to a kml file of 1.12 MB)
- each route is coloured in alternating colours such that individual segments can be distinguished from a connected route (e.g. routes on a connected 10 day route are coloured red for even days, blue for uneven days)
- for each track/ segment additional metadata is added, describing route length and accumulated elevation (styled with emojis, e.g. 🚴🏽♀️🚴🏼♂️)
- place all gpx tracks into folder
inputtracks
- name files according to desired sorting order, here I used
TIMESTAMP_xx Routename.gpx
wherexx
is used for the track color- routes on the same day which consist of 2 segments (e.g. recorded before/ after a ferry ride) but should share the same colour should be named with an underscore, e.g.
xx = 31_1
or31_2
- adjust the script if you have a different naming scheme/ want a different styling
- routes on the same day which consist of 2 segments (e.g. recorded before/ after a ferry ride) but should share the same colour should be named with an underscore, e.g.
merged_kml.kml
can be directly uploaded to google mymaps. Individual styles are applied according to the route index and the metadata is displayed when clicking on the route segment.
Check out a map styled with this script here.
Each time the script is called, all routes are processed. To speed things up it is conceivable to:
- store shrinked gpx files temporarily
- or append new gpx files to the kml file
This script uses