【发布时间】:2020-05-05 19:35:41
【问题描述】:
我想使用 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 文件中,必须被访问并充当系列的键才能获取日期。
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],...
data_AU_series(我想在地图上显示的数据(pd.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)
【问题讨论】:
标签: python pandas geojson folium