小册子朱皮特情节颜色密度热图 [英] leaflet jupyter plot color density heat map
问题描述
我正在研究一个熊猫csv数据框,并且使用 ipyleaflet
在jupyter中了解到,可以绘制到地图上.
I'm working on a pandas csv dataframe and came to know in jupyter using ipyleaflet
you can plot to a map.
到目前为止,我的代码是这样的
My code so far looks like this
from ipyleaflet import Map, Marker, MarkerCluster
longitudes = df['Longitude'].values.tolist()
latitudes = df['Latitude'].values.tolist()
markers = []
for lon,lat in zip(longitudes, latitudes):
markers.append(Marker(location=(lat, lon)))
m = Map(center=(latitudes[0], longitudes[0]), zoom=10)
marker_cluster = MarkerCluster(
markers=markers
)
m.add_layer(marker_cluster);
m
哪个很好,但是后来我看到了
Which is nice but then I saw this
我也有相同的字段 Economic Need Index
(经济需求索引),所以我也想这样做,也很好奇如何也可以切换到不太繁忙的 CartoDB
地图./p>
I also have the same field Economic Need Index
so I also want to do the same and also curious how I can also switch to the CartoDB
less busy map.
推荐答案
Since the last version of ipyleaflet it is now possible to create a HeatMap:
from ipyleaflet import Map, Heatmap
from random import uniform
m = Map(center=[0, 0], zoom=2)
# Create a random heatmap
locations = [
[uniform(-80, 80), uniform(-180, 180), uniform(0, 1000)] # lat, lng, intensity
for i in range(1000)
]
heat = Heatmap(locations=locations, radius=20, blur=10)
m.add_layer(heat)
# Change some attributes of the heatmap
heat.radius = 30
heat.blur = 50
heat.max = 0.5
heat.gradient = {0.4: 'red', 0.6: 'yellow', 0.7: 'lime', 0.8: 'cyan', 1.0: 'blue'}
m
此外,如果要切换到不太繁忙的地图",则可以在创建底图时更改底图:
Also, if you want to switch to a "less busy map", you can change the basemap when creating it:
from ipyleaflet import Map, basemaps
m = Map(center=(52, 10), zoom=8, basemap=basemaps.CartoDB.DarkMatter)
m
您还可以在给定图块的URL的情况下创建TileLayer,您可以在文档
And you can also create a TileLayer given the url of the tiles, you can find examples in the documentation
这篇关于小册子朱皮特情节颜色密度热图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!