gemgis.vector.explode_linestring#

gemgis.vector.explode_linestring(linestring: shapely.geometry.linestring.LineString) List[shapely.geometry.point.Point]#

Exploding a LineString to its vertices, also works for LineStrings with Z components

Parameters

linestring (shapely.geometry.linestring.LineString) – Shapely LineString from which vertices are extracted, e.g. linestring = LineString([(0, 0), (10, 10), (20, 20)])

Returns

points_list – List of extracted Shapely Points

Return type

List[shapely.geometry.point.Point]

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 points
>>> linestring_exploded = gg.vector.explode_linestring(linestring=linestring)
>>> linestring_exploded
[<shapely.geometry.point.Point at 0x20118cb27f0>,
<shapely.geometry.point.Point at 0x20118cb28b0>,
<shapely.geometry.point.Point at 0x20118cb26d0>]
>>> # Inspecting the first element of the list
>>> linestring_exploded[0].wkt
'POINT (0 0)'
>>> # Inspecting the second element of the list
>>> linestring_exploded[1].wkt
'POINT (10 10)'
>>> # Inspecting the third element of the list
>>> linestring_exploded[2].wkt
'POINT (20 20)'

See also

explode_linestring_to_elements

Exploding a LineString with more than two vertices into single LineStrings