gemgis.vector.explode_geometry_collection#

gemgis.vector.explode_geometry_collection(collection: shapely.geometry.collection.GeometryCollection) List[shapely.geometry.base.BaseGeometry]#

Exploding a Shapely Geometry Collection to a List of Base Geometries

Parameters

collection (shapely.geometry.collection.GeometryCollection) – Shapely Geometry Collection consisting of different Base Geometries

Returns

collection_exploded – List of Base Geometries from the original Geometry Collection

Return type

List[shapely.geometry.base.BaseGeometry]

New in version 1.0.x.

Example

>>> # Loading Libraries and creating Geometry Collection
>>> import gemgis as gg
>>> from shapely.geometry import LineString
>>> a = LineString([(0, 0), (1, 1), (1,2), (2,2)])
>>> b = LineString([(0, 0), (1, 1), (2,1), (2,2)])
>>> collection = a.intersection(b)
>>> collection.wkt
'GEOMETRYCOLLECTION (POINT (2 2), LINESTRING (0 0, 1 1))'
>>> # Exploding Geometry collection into single Base Geometries
>>> collection_exploded = gg.vector.explode_geometry_collection(collection=collection)
>>> collection_exploded
[<shapely.geometry.point.Point at 0x1faf63ccac0>,
<shapely.geometry.linestring.LineString at 0x1faf63ccb80>]
>>> # Inspecting the first element of the list
>>> collection_exploded[0].wkt
'POINT (2 2)'
>>> # Inspecting the second element of the list
>>> collection_exploded[1].wkt
'LINESTRING (0 0, 1 1)'

See also

explode_geometry_collections

Exploding a GeoDataFrame containing different Base Geometries