Warning
This code was generated in part by an AI assistant. While I have reviewed and modified it, I make no claims of exclusive ownership. This repository is provided "as-is" without any warranty or guarantee of originality or suitability for any purpose. Users should conduct their own due diligence before use.
This repository contains a script to convert KML (Keyhole Markup Language) files to Google Maps URLs with the aim of allowing navigation along the route with Google Maps as best as possible.
While Google Maps offers the option to generate custom routes with the My Maps feature, Google Maps does not by default allow you to follow along that exact route. While other mapping solutions exist that allow you to follow along exact routes like OsmAnd or Outdooractive they fall short in other areas such as traffic statistics or rerouting in case of construction work.
In addition to that, Google Maps has a limitation of 9 waypoints per route, which makes it difficult to set up longer trips with a specific paths manually.
- Converts KML to Google Maps URLs
- Customizable waypoint amount
- Route "splitting" with more than 9 Waypoints
- Two waypoint selection algorithms
- RDP (Ramer–Douglas–Peucker algorithm)
- Even distribution
- No external dependencies
- Python >= 3.11.x
- Either Download
kml-to-gmaps.py
or clone the repository usinggit clone https://github.com/RotusMaximus/kml-to-gmaps
- Open your Terminal
- Navigate to the folder you placed the script in
- Call the script like so
python kml_to_gmaps.py <KML_FILE_NAME_OR_PATH>.kml
- Done! You should see the output URL in your Terminal window
Using five waypoints using even distribution:
python kml_to_gmaps.py route.kml -n 5 -m even
Using 18 waypoints using a cycling route:
python kml_to_gmaps.py route.kml -n 18 -t bicycling
Parameter | Description | Default | Possible Values |
---|---|---|---|
-h --help |
Shows the help message. | - | |
-n --num_waypoints |
Total number of intermediate waypoints desired for the route. If > 9, multiple URLs will be generated. | 9 | Any Number |
-m --method |
Waypoint selection method: 'even' (evenly distributed) or 'rdp' (significant points). | rdp |
rdp , even |
-t --travelmode |
Google Maps travel mode. | driving |
driving ,walking ,bicycling ,two-wheeler ,transit |
-o --output |
Optional file path to save the generated URLs (one URL per line). | - | Absolute or relative file path |