在我的原始帖子中,我试图创建我的地图时遇到了一个错误,但我想我成功地通过了。我确定我没有选择正确的key_on
功能,但不确定为什么这不会显示正确的图像。请帮帮我!
我从这里拿到了我的文件http://adamw523.com/toronto-geojson/
我希望得到这样的东西。你知道吗
这就是我所尝试的
df_crime=pd.DataFrame(df.Neighbourhood)
df_crime['premisetype']=pd.DataFrame(df.premisetype)
df_crime['offence']=pd.DataFrame(df.offence)
df_crime['MCI']=pd.DataFrame(df.MCI) #major crime indicators e.g. Theft
df_crime['occurrencedate']=pd.DataFrame(df.occurrencedate)
df_crime['reporteddate']=pd.DataFrame(df.reporteddate)
df_crime['occurrencehour'] = df_crime.occurrencedate.dt.strftime('%H:%M')
df_crime['reportedyear'] = df_crime.reporteddate.dt.strftime('%Y')
df_crime['reportedmonth'] = df_crime.reporteddate.dt.strftime('%m')
df_crime['reportedday'] = df_crime.reporteddate.dt.strftime('%d')
df_crime['reportedhour'] = df_crime.reporteddate.dt.strftime('%H:%M')
df_crime['Lat']=pd.DataFrame(df.Lat)
df_crime['Long']=pd.DataFrame(df.Long)
df_crime.head()
我使用的坐标是:
多伦多=43.70011 多伦多长=-79.4163
我也有这个密码给我计数
df_crime1=df_crime.groupby('Neighbourhood').size().reset_index(name="Count")
world_geo = r'simple.geojson' # geojson file
# create map of Toronto using latitude and longitude values
map_toronto = folium.Map(location=[TORONTO_LAT,TORONTO_LONG ], zoom_start=10)
folium.Choropleth(geo_data=world_geo,
data=df_crime1,
columns=['Neighbourhood', 'Count'],
key_on='feature.properties.DAUID',
fill_color='YlOrRd',
fill_opacity=0.7,
line_opacity=0.2,
legend_name='Crime Rate in Toronto'
).add_to(map_toronto)
map_toronto
这是我得到的一张照片
我的问题是得到正确的答案。正确的冷使用方法如下。你知道吗
相关问题 更多 >
编程相关推荐