在折页地图上创建图例

2024-04-24 23:08:52 发布

您现在位置:Python中文网/ 问答频道 /正文

页文档此时不完整:https://folium.readthedocs.io/en/latest/

根据索引不完整的文档,图例和图层是,还是将被支持。我花了一些时间在网上寻找例子,但到目前为止什么也没有找到。如果有人知道如何创建这些东西,或可以给我一个文件或教程,我将非常感谢。


Tags: 文件文档httpsio图层readthedocs时间教程
3条回答

尝试使用

feature_group = FeatureGroup(name='Layer1')
feature_group2 = FeatureGroup(name='Layer2')

然后添加到地图中

map = folium.Map(zoom_start=6)

# coordinates to locate your marker
COORDINATE = [(333,333)] # example coordinate
COORDINATE2 = [(444,444)]

# add marker to your map
folium.Marker(location=COORDINATE).add_to(feature_group)
folium.Marker(location=COORDINATE2).add_to(feature_group2)

map.add_child(feature_group)
map.add_child(feature_group2)

# turn on layer control
map.add_child(folium.map.LayerControl())

Folium现在有一种方法可以在0.15版本中轻松添加图像。

from folium.plugins import FloatImage
image_file = 'image.PNG'

FloatImage(image_file, bottom=0, left=86).add_to(mymap)

你可以很容易地添加一个传说

#specify the min and max values of your data
colormap = branca.colormap.linear.YlOrRd_09.scale(0, 8500)
colormap = colormap.to_step(index=[0, 1000, 3000, 5000, 8500])
colormap.caption = 'Incidents of Crime in Victoria (year ending June 2018)'
colormap.add_to(world_map)

你可以在这里看到我完整的例子

Folium Map with legend example

相关问题 更多 >