【发布时间】:2020-02-01 01:06:03
【问题描述】:
我在将包含多边形顶点坐标的元组转换为 shapefile 时遇到问题。
元组对我来说是一种非常陌生的格式;如果它在数据框中,我可以使用 geopandas 轻松完成。
shape= ({'type': 'Polygon',
'coordinates': [[(-148.7285301097261, 60.42704276401832),
(-148.7285301097261, 60.42693172262919),
(-148.7285856304207, 60.42693172262919),
(-148.72830802694787, 60.42704276401832),
(-148.7285301097261, 60.42704276401832)]]},
1.0)
我无法通过pd.DataFrame(shape) 转换为数据帧;不能子集元组以通过shape['coordinates'] 或pd.DataFrame(list(shape)) 访问坐标。我已经查看了this 和this,但我一直坚持从元组结构中获取坐标!
给定此处显示的结构元组,我如何创建 shapefile(通过 Geopandas)?
【问题讨论】:
-
我可能错了,但在我看来,您同时要求的事情太多了。 1)How to access an item in a tuple; 2)How to convert GeoJSON to a GeoPandas dataframe;和 3)How to write a GeoPandas dataframe to a shapefile。我投票结束这个问题,因为“需要更多关注”。
标签: pandas tuples shapefile geopandas shapely