我正在尝试使用Folium为加拿大绘制一些数据。但是,最后,我得到空白作为输出,没有错误消息。我的代码在下面。
import folium
import json # or import geojson
with open("geo.json") as json_file:
json_data = json.load(json_file) # geojson file
# create a plain world map
can_map = folium.Map(location=[56.1, 106], zoom_start=2, tiles='Mapbox
Bright')
c2 = {
'Alberta': 144284.48,
'British Columbia': 141222.06000000017,
'Manitoba': 134337.96999999994,
'New Brunswick': 115727.67000000001,
'Newfoundland': 6885.140000000001,
'Northwest Territories': 91755.44000000002,
'Nova Scotia': 80136.18000000005,
'Nunavut': 1506.4300000000014,
'Ontario': 352263.50999999983,
'Prince Edward Island': 28742.2,
'Quebec': 138658.87999999998,
'Saskachewan': 177314.26000000013,
'Yukon': 74404.80000000003
}
# generate choropleth map using the total immigration of each country to Canada from 1980 to 2013
can_map.choropleth(
geo_data=json_data,
data=c2,
columns=['Province', 'Profit'],
key_on='feature.properties.name',
fill_color='YlOrRd',
fill_opacity=0.7,
line_opacity=0.2,
legend_name='Canada data'
)
# display map
can_map
我正在使用的json文件可以找到here