gemgis.vector.calculate_midpoint_linestring#

gemgis.vector.calculate_midpoint_linestring(linestring: shapely.geometry.linestring.LineString) shapely.geometry.point.Point#

Calculating the midpoint of a LineString with two vertices

Parameters

linestring (shapely.geometry.linestring.LineString) – LineString consisting of two vertices from which the midpoint will be extracted, e.g. linestring = LineString([(0, 0), (20, 20)])

Returns

point – Shapely Point representing the midpoint of the LineString

Return type

shapely.geometry.point.Point

New in version 1.0.x.

Example

>>> # Loading Libraries and creating LineString
>>> import gemgis as gg
>>> from shapely.geometry import Point, LineString
>>> linestring = LineString([(0, 0), (20, -20)])
>>> linestring.wkt
'LINESTRING (0 0, 20 -20)'
>>> # Calculating the midpoint of a LineString
>>> midpoint = gg.vector.calculate_midpoint_linestring(linestring=linestring)
>>> midpoint.wkt
'POINT (10 -10)'

See also

calculate_midpoints_linestrings

Calculating the midpoints of LineStrings

Note

The LineString must only consist of two points (start and end point)