如何正确访问geojson文件?

问题描述 投票:-1回答:1

我想使用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],...

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
1个回答
0
投票
它与第二个键['STATE_NAME']一起使用

colormap(data_AU_series[feature['properties']['STATE_NAME']]

© www.soinside.com 2019 - 2024. All rights reserved.