Reputation: 404
How can i get the values of coordinate in a POLYGON in a Geopandas Dataframe?
shapefile = gpd.read_file("CAMPOS_PRODUCAO_SIRGASPolygon.shp")
I can easy do it for a centroid of my POLYGON
with it:
print(campos_shape.centroid.iloc[0].x)
-39.853276865819765
print(type(campos_shape.centroid.iloc[0].x))
<class 'float'>
I want a list or numpy array with all point value of lat and lon contained in POLYGON
So how can i convert a POLYGON to numpy array?
Upvotes: 2
Views: 8827
Reputation: 404
If anyone else has this problem, here is one solution that work for me:
def coord_lister(geom):
coords = list(geom.exterior.coords)
return (coords)
coordinates_list = your_geopandas_df.geometry.apply(coord_lister)
Upvotes: 5
Reputation: 681
Update: This for example gives you the coordinates of the polygon for the first entry in the shapefile:
list(shapefile["geometry"][0].exterior.coords)
Upvotes: 2