gemgis.vector.explode_linestring_to_elements#

gemgis.vector.explode_linestring_to_elements(linestring: shapely.geometry.linestring.LineString) List[shapely.geometry.linestring.LineString]#

Separating a LineString into its single elements and returning a list of LineStrings representing these elements, also works for LineStrings with Z components

Parameters

linestring (linestring: shapely.geometry.linestring.LineString) – Shapely LineString containing more than two vertices, e.g. linestring = LineString([(0, 0), (10, 10), (20, 20)])

Returns

splitted_linestrings – List containing the separate elements of the original LineString stored as LineStrings

Return type

List[shapely.geometry.linestring.LineString]

New in version 1.0.x.

Example

>>> # Loading Libraries and creating LineString
>>> import gemgis as gg
>>> from shapely.geometry import LineString
>>> linestring = LineString([(0, 0), (10, 10), (20, 20)])
>>> linestring.wkt
'LINESTRING (0 0, 10 10, 20 20)'
>>> # Exploding LineString into single elements
>>> linestring_exploded = gg.vector.explode_linestring_to_elements(linestring=linestring)
>>> linestring_exploded
[<shapely.geometry.linestring.LineString at 0x201448a2100>,
<shapely.geometry.linestring.LineString at 0x20144b5e610>]
>>> # Inspecting the first element of the list
>>> linestring_exploded[0].wkt
'LINESTRING (0 0, 10 10)'
>>> # Inspecting the second element of the list
>>> linestring_exploded[1].wkt
'LINESTRING (10 10, 20 20)'

See also

explode_linestring

Exploding a LineString into its single vertices