这是我的新手,正在制作Choropleth地图,所以请忍受...
我正在尝试绘制多伦多犯罪的热图(切入点)。我正在使用https://open.toronto.ca/dataset/neighbourhoods/中的geojson文件。
这是我的代码:
!wget -q -O 'Neighbourhoods.geojson' https://open.toronto.ca/dataset/neighbourhoods/
print('Data downloaded!')
Tor_geo = r'Neighbourhoods.geojson'
#calculate the total number of incidences per neighborhood in Toronto
Tor_crime = pd.DataFrame(TCrimedf['Neighbourhood'].value_counts().astype(float))
#Tor_crime.to_csv('TorCrimeagg.csv')
#Tor_crime.to_json('TorCrimeagg.json')
Tor_crime = Tor_crime.reset_index()
Tor_crime.columns = ['Neighbourhood', 'Number']
Tor_crime.head(5)
#create choropleth map of toronto crime
TorCrime_map = folium.Map(location=[43.6534817, -79.3839347], tiles='openstreetmap')
TorCrime_map.choropleth(
geo_data =Tor_geo,
data = Tor_crime,
#data_out = 'TorCrimeagg.json'
#data = TCrimedf,
columns = ['Neighbourhood','Number'],
key_on ='features.properties.AREA_NAME',
zoom_start=12,
fill_color='YlOrRd',
fill_opacity=0.7,
line_opacity=0.2,
legend_name="Crimes in Toronto"
)
TorCrime_map
运行此命令后,出现以下错误消息:
geojson文件如下:
我尝试使用其他geojson文件,但遇到相同的错误。
是我加载geojson文件的方式吗?我想念什么吗?
我将感谢您的帮助!并预先感谢您!