【发布时间】:2022-01-16 10:20:26
【问题描述】:
我对folium 地图的经验很少。 我需要用每个部门的机构数量制作一张地图,问题是首都的机构数量远远多于内部,所以当我创建颜色层时,我将首都设为深蓝色,其余的都一样较浅的颜色。这样地图就没那么有用了…… 我怎么能解决这个问题?我想也许将值除以人口,但最好使用原始值。 在文档中,我没有找到参数化颜色的方法。
df1 = pd.DataFrame({'code':['75','77','78','91','92','93','94','95'],'value':['13000','2000','2500','2300','2150','2600','1630','1300']})
dep_geo = geopandas.read_file('./dep.json', driver="JSON") #geodata taken from https://github.com/gregoiredavid/france-geojson/blob/master/departements.geojson
departments = {'75', '77', '78', '91', '92', '93', '94', '95'}
dep_geo = dep_geo[dep_geo['code'].isin(departments)]
df_map = dep_geo.merge(df1, how="left", left_on=['code'], right_on=['code'])
my_map = folium.Map(location=[48.856614, 2.3522219],
zoom_start = 9, tiles='cartodbpositron')
folium.Choropleth(
geo_data=df_map,
data=df_map,
columns=['code',"value"],
key_on="feature.properties.code",
fill_color='YlGnBu',
fill_opacity=0.5,
line_opacity=0.2,
legend_name="value ",
smooth_factor=0,
Highlight= True,
line_color = "black",
name = "value",
show=False,
overlay=True,
nan_fill_color = "White"
).add_to(my_map)
感谢您的帮助!
【问题讨论】:
标签: python maps geopandas folium