绘制等值线图仅绘制数据框的最后一个元素

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

我使用 Plotly express choropleth 将一些数据绘制到地图中,但它仅为输入数据帧的最后一个元素绘制边界线。如果正确给出了单独的行,它会为每个区域绘制一条边界线。这是一个输入数据框, [1]:https://i.stack.imgur.com/22fz7.png 这是给出的输出, [2]:https://i.stack.imgur.com/VAH8u.png 这是我使用的代码块,

fig = px.choropleth(grand_summery,geojson=geo_data,color='total_cases', locations='district',featureidkey='properties.ADM2_EN') fig.update_geos(fitbounds='locations', visible=False) fig.show()

我从这个仓库获得的geojson文件 - https://github.com/MalakaGu/Sri-lanka-maps/blob/master/discrict_map/District_geo.json

数据帧作为 csv 文件 - https://github.com/ashen007/SL_COVID_analysis/blob/master/data/exp_df.csv

python plotly
1个回答
0
投票

同样的事情也发生在我身上,罗马尼亚的县,我通过使用以下代码片段反转每个要素多边形的坐标顺序来修复它,就在从 geojson 文件加载数据之后:

for feature in geodata["features"]:
    for polygon in feature["geometry"]["coordinates"]:
        for coords in polygon:
            coords.reverse()
最新问题
© www.soinside.com 2019 - 2024. All rights reserved.