【发布时间】:2022-01-08 04:02:23
【问题描述】:
我有一个 geopandas 数据框 df,它看起来像这样:
st_astext 列设置为数据框几何。我正在尝试将其绘制为一个 plotly mapbox chloropleth map,其颜色与cnt 中的多边形成比例st_astext,使用
trcs = [px.choropleth_mapbox(df, geojson=df.geometry, locations=df['id'], color='cnt', color_continuous_scale="Viridis")]
lout = go.Layout(title='ch', mapbox_accesstoken=mapToken, width=1600, height=1200, mapbox={'style':'streets', 'zoom':10.5,'center':{'lat':boundingBox['centroid_lat'].values[0], 'lon':boundingBox['centroid_lon'].values[0]}})
plyoff.iplot(go.Figure(data=trcs, Layout=lout))
这给了我这个部分堆栈跟踪:
ValueError:
Invalid element(s) received for the 'data' property of
Invalid elements include: [Figure({
'data': [{'coloraxis': 'coloraxis',
'geojson': {'bbox': (-118.28177341, 33.7155889101773,
-118.18514585495, 33.7780896175267),
'features': [{'bbox': (-118.279454401, 33.7495355583513,
-118.271920681, 33.756297219837),
'geometry': {'coordinates': (((-118.279454
401,
33.754490905),
(-118.27537536
6211, 33.74953
55583513), (-1
18.271920681,
33.75105207235
19), (-118.275
847434998, 33.
756297219837),
(-118.27945440
1, 33.75449090
5))),
'type': 'Polygon'},
'id': '0',
'properties': {},
'type': 'Feature'},...
有什么想法吗?我可能完全错了,但是这种绘图的文档似乎还有很多不足之处。我尝试了各种排列,但没有运气。
【问题讨论】:
标签: python plotly mapbox geopandas