簡體   English   中英

如何正確訪問geojson文件?

[英]How to access the geojson file correctly?

我想使用 folium 和 GeoJSON 文件來處理世界 map 上的 map 數據。 因此我必須正確訪問 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 文件中,必須訪問並充當系列的鍵才能獲取日期。

GeoJSON 文件中的geodata_australia

{'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)

它與第二個鍵 ['STATE_NAME'] 一起使用

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM