Jam*_*s.F 2 python json dictionary choropleth
我收到此错误:不推荐使用 choropleth 方法。而是使用具有相同参数的新 Choropleth 类。有关如何执行此操作,请参阅示例笔记本“GeoJSON_and_choropleth”。
with open('C:/Users/abcdef/Desktop/world_countries.json') as data_file:
data = json.load(data_file)
world_geo = data
world_map = folium.Map(location=[0, 0], zoom_start=2, tiles = 'Mapbox Bright')
world_map.choropleth(
geo_data = world_geo,
data = canadamap,
columns = ['Country', 'Total'],
key_on = 'feature.properties.name',
fill_color = 'YlOrRd',
fill_opacity = 0.7,
line_opacity = 0.2,
legend_name = 'Immigration to Canada'
)
world_map
Run Code Online (Sandbox Code Playgroud)
我没有使用上面的代码获得 Choropleth Map;相反,我得到
choropleth 方法已被弃用。而是使用具有相同参数的新 Choropleth 类。有关如何执行此操作,请参阅示例笔记本“GeoJSON_and_choropleth”。
小智 9
这应该对你有用。该方法已修改为 Choropleth 而不是 choropleth。你应该有
folium.Choropleth(args*).add_to(world_map)
Run Code Online (Sandbox Code Playgroud)
在所有
world_geo = r'world_countries.json' # geojson file
# create a plain world map
world_map = folium.Map(location=[0, 0], zoom_start=2, tiles='Mapbox Bright')
# generate choropleth map using the total immigration of each country to Canada from 1980 to 2013
folium.Choropleth(
geo_data=world_geo,
data=df_can,
columns=['Country', 'Total'],
key_on='feature.properties.name',
fill_color='YlOrRd',
fill_opacity=0.7,
line_opacity=0.2,
legend_name='Immigration to Canada'
).add_to(world_map)
# display map
world_map
Run Code Online (Sandbox Code Playgroud)
我希望这有帮助