叶片在Choropleth贴图上不显示颜色

时间:2019-06-26 18:55:03

标签: python-3.x gis geopandas folium

我正在尝试根据社区结构创建大叶藻类的地图,但该地图无法填充颜色。

def mapThese():
    comm_types = ['1950s','1960s/1970s','1980s/1990s','2000s','INNERCITY','CENTRE CITY','BUILDING OUT','UNDEVELOPED','EMPLOYMENT']
    gdf=gpd.read_file('Census by Community 2018.geojson')
    #gdf_wgs84 = gdf.to_crs({'init': 'epsg:4326'})
    gdf.crs = {'init': 'epsg:4326'}
    gdf['id_field'] = range(1,len(gdf)+1)
    gdf['comm_type'] = gdf['comm_structure'].apply(lambda x: comm_types.index(x) if x in comm_types else len(comm_types))
    folium_map = folium.Map(location=[51.044270, -114.06209], zoom_start=13,prefer_canvas = True)
    folium.Choropleth(geo_data=gdf,
                      name='choropleth',
                      data=gdf,
                      columns=['id_field','comm_type'],
                      key_on='feature.id',
                      bins=range(0,len(comm_types)+1),
                      fill_color='YlOrRd',
                      fill_opacity=0.5,
                      line_color='black',
                      legend_name='Community Structures',
                      overlay=True,
                      reset=True
                      ).add_to(folium_map)
    folium_map.save('Communities.html')
    return

地图上没有显示颜色。

请帮助。

0 个答案:

没有答案