Python 无法使用我的代码获取Choropleth地图:请引导,谢谢
我收到这个错误:choropleth方法已被弃用。而是使用具有相同参数的新Choropleth类。请参阅示例笔记本“GeoJSON_和_choropleth”,了解如何做到这一点Python 无法使用我的代码获取Choropleth地图:请引导,谢谢,python,json,dictionary,choropleth,Python,Json,Dictionary,Choropleth,我收到这个错误:choropleth方法已被弃用。而是使用具有相同参数的新Choropleth类。请参阅示例笔记本“GeoJSON_和_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]
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
我没有使用上面的代码获得Choropleth地图;相反,我得到了
choropleth方法已被弃用。而是使用具有相同参数的新Choropleth类。请参阅示例笔记本“GeoJSON_和_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
这应该对你有用。该方法已修改为Choropleth而非Choropleth。 你应该
folium.Choropleth(args*).add_to(world_map)
总共
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
我希望这对你有所帮助这条信息告诉你你需要知道的一切。您需要使用
Choropleth
类,因为该方法不再受支持。您需要阅读文档,以了解这将如何改变执行。