gemgis.vector.calculate_midpoints_linestrings#

gemgis.vector.calculate_midpoints_linestrings(linestring_gdf: Union[geopandas.geodataframe.GeoDataFrame, List[shapely.geometry.linestring.LineString]]) List[shapely.geometry.point.Point]#

Calculating the midpoints of LineStrings with two vertices each

Parameters

linestring_gdf (Union[gpd.geodataframe.GeoDataFrame, List[shapely.geometry.linestring.LineString]]) – GeoDataFrame containing LineStrings or list of LineStrings of which the midpoints will be calculated

Returns

midpoint_list – List of Shapely Points representing the midpoints of the provided LineStrings

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 Point, LineString
>>> linestring = LineString([(0, 0), (20, -20)])
>>> linestring.wkt
'LINESTRING (0 0, 20 -20)'
>>> # Creating list of LineStrings
>>> linestring_list = [linestring, linestring]
>>> # Calculating midpoints from LineStrings
>>> midpoints = gg.vector.calculate_midpoints_linestrings(linestring_gdf=linestring_list)
>>> midpoints
[<shapely.geometry.point.Point at 0x231ea982880>,
 <shapely.geometry.point.Point at 0x231ea982700>]
>>> # Inspecting the first element of the list
>>> midpoints[0].wkt
'POINT (10 -10)'
>>> # Inspecting the second element of the list
>>> midpoints[1].wkt
'POINT (10 -10)'

See also

calculate_midpoint_linestring

Calculating the midpoint of one LineString