I read a shapefile with GeoPandas and I get a nice table with a column "geometry"
. This column contains shapely.geometry.polygon.Polygon
or shapely.geometry.multipolygon.MultiPolygon
object.
import geopandas as gpd
gdf = gpd.GeoDataFrame.from_file("ashapefile.shp")
Now I would like to use this geoDataFrame to make such as a chloropeth plot or something else. Thus I would like to get the (x, y) coordinates, (latitude, longitude) of these polygons.
For example if I do :
for boundary in gdf.boundary:
print(boundary.xy)
Thus boundary
are shapely.geometry.linestring.LineString
or MultiLineString
. boundary.xy
are what I am looking for. But for MultilineString I have to do a loop on all the line.
Is there the way to do that ? Or is there a more simple or straightforward way ?
EDIT :
Issue with unary_union
: