嗨,我在尝试创建Choropleth映射时遇到错误。 这是我的代码。顺便说一句,我正在使用Jupyter笔记本
with open('C:/.../../Downloads/london_boroughs.json') as f:
data=json.load(f)
map = folium.Map(location=[latitude, longitude],tiles='cartodbpositron' ,zoom_start=11)
data=df
state_geo = data
choropleth = folium.Choropleth(
geo_data=state_geo,
name='choropleth',
data=df,
columns=['BoroughName', 'MonthlyAverage'],
key_on='feature.properties',
fill_color='YlGn',
fill_opacity=0.7,
line_opacity=0.2,
legend_name='MonthlyAverage',
highlight=True,
line_color='black'
).add_to(map)
folium.LayerControl(collapsed=True).add_to(map)
map
输出为:
-------------------------------------------------- -------------------------
ValueError跟踪(最近一次通话)
在
ValueError:无法渲染缺少任何几何形状的对象:BoroughName MonthlyAverage人口纬度经度\
0吠叫和达格纳姆1616.083333 194352 51.5607 0.1557
1巴尼特2494.875000 369088 51.6252 -0.1517
2 Bexley 1412.791667 236687 51.4549 0.1505
df represent a dataframe of crimes