gpt4 book ai didi

python - 使用 Folium 在 map 上的新图层中打印一条线/多线

转载 作者:太空狗 更新时间:2023-10-29 20:15:42 29 4
gpt4 key购买 nike

我已经尝试过 Python folium 库并取得了令人印象深刻的结果,但是我缺少一个功能,或者在任何情况下我都找不到:我想在 map 上的新图层中打印多线。

如果我查看文档,我只能找到如何添加标记和多边形标记。但是关于在新层中打印,我只能找到例子like this one .

我需要比这简单得多的东西。我想我可以以类似的方式插入带有多行信息的 GeoJSON,但我什至无法找到 GeoJSON 应该具有哪种格式。

有什么想法让我的多行吗?

PD:如果您不知道如何使用 Python/Folium 实现此目的,我将很高兴听到我应该向 Javascript 输出添加什么以使用 Leaflet 获得多行(这就是 Folium 库正在使用的)。

最佳答案

前面示例中的一些函数现在已被弃用;显然,现在首选的方法是这样的:

import folium

# Coordinates are 10 points on the great circle from Boston to
# San Francisco.
# Reference: http://williams.best.vwh.net/avform.htm#Intermediate
coordinates = [
[42.3581, -71.0636],
[42.82995815, -74.78991444],
[43.17929819, -78.56603306],
[43.40320216, -82.37774519],
[43.49975489, -86.20965845],
[41.4338549, -108.74485069],
[40.67471747, -112.29609954],
[39.8093434, -115.76190821],
[38.84352776, -119.13665678],
[37.7833, -122.4167]]

# Create the map and add the line
m = folium.Map(location=[41.9, -97.3], zoom_start=4)
my_PolyLine=folium.PolyLine(locations=coordinates,weight=5)
m.add_child(my_PolyLine)
# m.save('line_example_newer.html')

关于python - 使用 Folium 在 map 上的新图层中打印一条线/多线,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23905822/

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