Track colored with a custom color map

This example will create a map and color the track according to the velocity using a custom color map, instead of a pre-defined one.

Note

The velocities are calculated from the distance so it is a bit noisy.

Make this Notebook Trusted to load map: File -> Trust Notebook


from branca.colormap import LinearColormap

from gpxplotter import add_segment_to_map, create_folium_map, read_gpx_file

line_options = {"weight": 8}

color_map = LinearColormap(["#00ff00", "#ff0000"])

the_map = create_folium_map(tiles="openstreetmap")
for track in read_gpx_file("example2.gpx"):
    for i, segment in enumerate(track["segments"]):
        add_segment_to_map(
            the_map,
            segment,
            color_by="velocity-level",
            cmap=color_map,
            line_options=line_options,
        )

# To store the map as a HTML page:
# the_map.save('map_011.html')

# To display the map in a Jupyter notebook:
the_map

Total running time of the script: (0 minutes 0.397 seconds)

Gallery generated by Sphinx-Gallery