在Python中的horopleth地图

问题描述 投票:-2回答:1

这是我的数据集。

This is my dataset

这是我的代码

This is my code

我得到了这个错误。

I'm getting this error

对于那些需要代码的人来说

canada_geo = r'canada_provinces.json'
# create a plain world map
canada_map = folium.Map(location=[56.1304, -106.3468], zoom_start=2, tiles='Mapbox Bright')
print(canada_geo)`

    canada_map.choropleth(
    geo_data=canada_geo,
    data=canada,
    columns=['abbreviation', 'Population'],
    key_on="features.properties.Abbreviation",
    fill_color='YlOrRd',
    fill_opacity=0.7, 
    line_opacity=0.2,
    legend_name='Population'
)

# display map
canada_map
python json python-3.x folium choropleth
1个回答
0
投票

错误就在这一行,正确的代码是:Canada_map = folium.Map(location=[56.1304,..:

key_on="features.properties.Abbreviation",

正确的代码是:

key_on="feature.properties.Abbreviation",

而你得到的是:

enter image description here

最新问题
© www.soinside.com 2019 - 2025. All rights reserved.