get_geometric_midpoint

pyhelpers.geom.get_geometric_midpoint(pt1, pt2, as_geom=False)[source]

Get the midpoint between two points.

Parameters:
  • pt1 (shapely.geometry.Point | list | tuple | numpy.ndarray) – One point.

  • pt2 (shapely.geometry.Point | list | tuple | numpy.ndarray) – Another point represented similarly to pt1.

  • as_geom (bool) – Whether to return shapely.geometry.Point; defaults to False.

Returns:

The midpoint between pt1 and pt2.

Return type:

tuple | shapely.geometry.Point | None

Examples:

>>> from pyhelpers.geom import get_geometric_midpoint
>>> pt_1, pt_2 = (1.5429, 52.6347), (1.4909, 52.6271)
>>> geometric_midpoint = get_geometric_midpoint(pt_1, pt_2)
>>> geometric_midpoint
(1.5169, 52.6309)
>>> geometric_midpoint = get_geometric_midpoint(pt_1, pt_2, as_geom=True)
>>> geometric_midpoint.wkt
'POINT (1.5169 52.6309)'

See also