[英]How acess/get/extract the values of POLYGON in a geometry column of Geopandas Dataframe?
如何在 Geopandas 数据框中获取 POLYGON 中的坐标值?
shapefile = gpd.read_file("CAMPOS_PRODUCAO_SIRGASPolygon.shp")
我可以轻松地为我的 POLYGON 的质心做这件事
用它:
print(campos_shape.centroid.iloc[0].x)
-39.853276865819765
print(type(campos_shape.centroid.iloc[0].x))
<class 'float'>
我想要一个列表或 numpy 数组,其中包含 POLYGON 中包含的所有经纬度点值
那么如何将 POLYGON 转换为 numpy 数组?
更新:例如,这为您提供 shapefile 中第一个条目的多边形坐标:
list(shapefile["geometry"][0].exterior.coords)
如果其他人有这个问题,这里有一个对我有用的解决方案:
def coord_lister(geom):
coords = list(geom.exterior.coords)
return (coords)
coordinates_list = your_geopandas_df.geometry.apply(coord_lister)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.