Skip to content

Simplify and merge individual gpx tracks into a single styled kml file

License

Notifications You must be signed in to change notification settings

ilorevilo/kml-routemap

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 

Repository files navigation

Simplify and merge individual gpx tracks into a single styled kml file

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. 🚴🏽‍♀️🚴🏼‍♂️)

input

  • place all gpx tracks into folder inputtracks
  • name files according to desired sorting order, here I used TIMESTAMP_xx Routename.gpx where xx 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 or 31_2
    • adjust the script if you have a different naming scheme/ want a different styling

output

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.

to improve

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

credits

This script uses

  • gpxpy for reading & shrinking the input tracks
  • simplekml for styling and saving the kml file.

About

Simplify and merge individual gpx tracks into a single styled kml file

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published