Folium HeatmapWithTime

时间:2018-04-10 17:52:44

标签: python heatmap folium

我有一个如下所示的数据框:

ID                     LAT           LON      VALUE COUNT
81215545953683710540   48.847306     2.433284   0   1
74994612102903447699   48.861935     2.441292   1   1
48126186377367976994   48.839644     2.655109   1   1
23522333658893375671   48.924351     2.386369   4   3
16194691060240380504   48.829872     2.376677   8   1 

每个ID都有一个坐标,一个VALUE对应一个时间间隔,一个COUNT表示有多少人在那里。

我想制作一个时间热图,显示所有具有相同VALUE的行,考虑到COUNT越大,点应该越大。< / p>

到目前为止,我成功地制作了热图,但我很难改变圆点的半径。所以每个点都有相同的大小,我不想要。

我对此处的文档了解的是,通常可以更改半径:http://python-visualization.github.io/folium/docs-v0.5.0/plugins.html#folium-plugins

到目前为止我的代码:

import folium
import folium.plugins as plugins
%matplotlib inline

heat_df = data

heat_df['Weight'] = heat_df['VALUE']
heat_df['Weight'] = heat_df['VALUE'].astype(float)
heat_df = heat_df.dropna(axis=0, subset=['LAT','LON', 'Weight'])

ma_heatmap = folium.Map(location=[48.512,2.2055],tiles= "OpenStreetMap",
                    zoom_start = 13)

heat_data = [[[row['LAT'],row['LON']] 
                for index, row in heat_df[heat_df['Weight'] == i].iterrows()] 
                 for i in range(0,145)] #value jusqu'à 145

hm = plugins.HeatMapWithTime(heat_data,auto_play=True,max_opacity=0.8, radius=heat_data['COUNT']*10) #here is my try to change the radius
hm.add_to(ma_heatmap)

ma_heatmap

我还制作了一个没有计数的静态热图,但是这里的值正在增加,所以我对这些点感到满意,但我无法将时间用于它。

看起来像这样:

import folium 
from folium import plugins
%matplotlib inline

m = folium.Map(location=[48.897634, 2.420086], zoom_start=7)

m.add_children(plugins.HeatMap([[row["LAT"], row["LON"]] for counts, row in data.iterrows()]))

m

无论哪种方式,我都无法计算两种方法来获得我想要的东西,如下所示:http://apps.socib.es/Leaflet.TimeDimension/examples/example12.html

如果有人有想法,我将不胜感激

0 个答案:

没有答案