绘制一个封闭且填充的轮廓

时间:2016-10-12 10:12:17

标签: python folium

我正在尝试绘制一个封闭的轮廓,用folium填充(透明或任何)颜色。缺乏文档没有帮助,任何想法如何做到这一点?

这是我目前的代码

m = folium.Map(location=[46, 2], zoom_start=5)

pts = [
[43.601795137863135, 1.451673278566412],
[43.61095574264419, 1.437239509310642],
[43.60999839038903, 1.45630473303456],
[43.60607351937904, 1.438762676051137],
[43.59725521090158, 1.444569790831369],
[43.6076281683173, 1.451991362348086]
]

p = folium.PolyLine(locations=pts,weight=5)
m.add_children(p)

2 个答案:

答案 0 :(得分:1)

这没有记录(没有真正记录的ATM),但这有效

m = folium.Map(location=[46, 2], zoom_start=5)

pts = [
[43.601795137863135, 1.451673278566412],
[43.61095574264419, 1.437239509310642],
[43.60999839038903, 1.45630473303456],
[43.60607351937904, 1.438762676051137],
[43.59725521090158, 1.444569790831369],
[43.6076281683173, 1.451991362348086]
]

folium.features.PolygonMarker(locations=pts, color='#FF0000', fill_color='blue', weight=5).add_to(m)

答案 1 :(得分:0)

要添加到Overdrivr的代码中,您还可以先制作点的凸包,以确定点所覆盖的区域。

from scipy.spatial import ConvexHull
import folium

m = folium.Map(location=[43.6, 1.43], zoom_start=13)

pts = [
[43.601795137863135, 1.451673278566412],
[43.61095574264419, 1.437239509310642],
[43.60999839038903, 1.45630473303456],
[43.60607351937904, 1.438762676051137],
[43.59725521090158, 1.444569790831369],
[43.6076281683173, 1.451991362348086]
]

b = [pts[i] for i in ConvexHull(pts).vertices]

folium.features.PolygonMarker(locations=b, color='#FF0000', fill_color='blue', weight=5).add_to(m)