[英]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.