get_geometric_midpoint_calc

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

Get the midpoint between two points by pure calculation.

See also [GEOM-GGMC-1] and [GEOM-GGMC-2].

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_calc
>>> pt_1, pt_2 = (1.5429, 52.6347), (1.4909, 52.6271)
>>> geometric_midpoint = get_geometric_midpoint_calc(pt_1, pt_2)
>>> geometric_midpoint
(1.5168977420748175, 52.630902845583094)
>>> geometric_midpoint = get_geometric_midpoint_calc(pt_1, pt_2, as_geom=True)
>>> geometric_midpoint.wkt
'POINT (1.5168977420748175 52.630902845583094)'

See also