使用Folium创建贴图并添加图层和颜色贴图(Python)

2024-05-16 13:10:51 发布

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

我正在使用Python中的Folium创建一个贴图,然后在该贴图中添加一个光栅,其中像素从-1到+1不等。我也使用彩色地图,但我的地图显示得很暗。然而,我可以看到传说。以下是我使用的代码:

colormap = cm.LinearColormap(colors=['red','lightblue'], vmin=-1,vmax=1)
map= folium.Map(location=[47.57157950, -2.82316415], 
              tiles = 'Stamen Terrain', zoom_start=13)

map.add_child(folium.raster_layers.ImageOverlay(dataimage,
    bounds=[[47.47813608, -2.98340958], [47.66479599, -2.66234847]]))

map.add_child(colormap)

#Save html
import webbrowser
map.save('mapme.html')
webbrowser.open("mapme.html")

为此,我得到以下输出

enter image description here


Tags: 代码addchildmaphtml光栅地图cm