Search code examples
pythonmapsfoliumgpx

Consistently coloring tracks by elevation across multiple maps with gpxplotter


I use gpxplotter and folium to generate maps from GPX tracks. I use the following method to color them based on elevation data:

add_segment_to_map(the_map, segment, color_by='elevation', cmap='YlOrRd_09')

Now, I would like to keep the colors consistent across multiple maps?

For example, if I have a track that runs from 0 to 1500 meters, 0 will be on one end of the spectrum (light yellow in my case) and 1500 on the other (red). Another track might go from 1000 and 2000 meters. The coloring for 0 meters of elevation in the first track is the same as for 1000 in the second (and equally for 1500 and 2000).

Rather than using the local elevation data of each map, is there a way to specify a global range, e.g. from 0 to 3000?


Solution

  • I modified gpxplotter to allow overwriting the range of the colormap. This allows:

    add_segment_to_map(the_map, segment, color_by='elevation', cmap='YlOrRd_09', min=0, max=3000)
    

    I created a pull request.