我想使用folium和GeoJSON文件在世界地图上映射数据。因此,我必须正确访问GeoJSON文件。但是我还不知道怎么做。
KeyError: "None of [Index(['STATE_CODE', 'STATE_NAME'], dtype='object', name='Province')] are in the [index]"
索引来自data_AU_series(pd.Series)
STATE_NAME在geoJSON文件中,必须被访问并作为Series的键来获取日期。
<< [geodata_australia来自GeoJSON文件:
{'type': 'FeatureCollection',
'features': [{'type': 'Feature',
'id': 0,
'properties': {'STATE_CODE': '1', 'STATE_NAME': 'New South Wales'},
'geometry': {'type': 'MultiPolygon',
'coordinates': [[[[159.10542, -31.563994],
[159.09775, -31.564275],
[159.099634, -31.573372],...
(我想在地图上显示的数据(pd.Series):data_AU_series
Province
Victoria 2020-03-24
...
我想将系列中的值分配给地理数据和颜色的代码行叶
folium.GeoJson(
geodata_australia,
name='data_AU',
style_function=lambda feature: {
'fillColor': colormap(data_AU_series[feature['properties']]),
'color': 'black',
'weight': 1,
'dashArray': '5, 5',
'fillOpacity': 0.9,
}
).add_to(m)
colormap(data_AU_series[feature['properties']['STATE_NAME']]