gemgis.vector.explode_polygons#

gemgis.vector.explode_polygons(gdf: geopandas.geodataframe.GeoDataFrame) geopandas.geodataframe.GeoDataFrame#

Converting a GeoDataFrame containing elements of geom_type Polygons to a GeoDataFrame with LineStrings

Parameters

gdf (gpd.geodataframe.GeoDataFrame) – GeoDataFrame created from vector data containing elements of geom_type Polygon

Returns

gdf_linestrings – GeoDataFrame containing elements of type MultiLineString and LineString

Return type

gpd.geodataframe.GeoDataFrame

New in version 1.0.x.

Example

>>> # Loading Libraries and creating Polygon
>>> import gemgis as gg
>>> import geopandas as gpd
>>> gdf = gpd.read_file(filename='file.shp')
>>> gdf
    geometry
0       POLYGON ((0.0 0.0, 1.0 1.0, 1.0 0.0, 0.0 0.0))
1       POLYGON ((0.0 0.0, 1.0 1.0, 1.0 0.0, 0.0 0.0))
>>> # Exploding Polygons into LineStrings
>>> gdf_exploded = gg.vector.explode_polygons(gdf=gdf)
>>> gdf_exploded
    geometry
0       LINESTRING (0.0 0.0, 1.0 1.0, 1.0 0.0, 0.0 0.0)
1       LINESTRING (0.0 0.0, 1.0 1.0, 1.0 0.0, 0.0 0.0)

See also

explode_polygon

Exploding a Polygon into single Points