gpt4 book ai didi

python - 如何在大叶上使用基于颜色的 PolyLine

转载 作者:行者123 更新时间:2023-12-04 16:28:28 26 4
gpt4 key购买 nike

我尝试使用 folium 根据速度(如 Strava 等应用程序)使用不同颜色的比赛路径。

我看到您可以根据数据更改标记的颜色,但我无法使用 PolyLines 将其转置。

这是我的可视化的代码:

points = []
for track in gpx.tracks:
for segment in track.segments:
for point in segment.points:
points.append(tuple([point.latitude, point.longitude]))

ave_lat = sum(p[0] for p in points)/len(points)
ave_lon = sum(p[1] for p in points)/len(points)

my_map = folium.Map(location=[ave_lat, ave_lon], zoom_start=13)
folium.PolyLine(points, color="red", weight=2.5, opacity=1).add_to(my_map)

我还有一个包含经度、纬度和速度的数据框,我希望线条根据速度改变颜色。

最佳答案

folium 有 ColorLine :

folium.ColorLine(
positions = segments, # tuple of coordinates
colors = speed, # map each segment with the speed
colormap = colormap, # map each value with a color
).add_to(base)

关于python - 如何在大叶上使用基于颜色的 PolyLine,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57903223/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com