pyufunc.calc_distance_on_unit_sphere#

pyufunc.calc_distance_on_unit_sphere(pt1, pt2, unit='km')#

Calculate the distance between two points on the unit sphere.

Parameters:
  • pt1 (Point | tuple | list | np.array) – the first point, in the format of (longitude, latitude)

  • pt2 (Point | tuple | list | np.array) – the second point, in the format of (longitude, latitude)

  • unit (str, optional) – distance unit, in “meter”, “km”, and “mile”. Defaults to ‘km’.

Returns:

the distance between two points on the unit sphere, or None if an error occurs

Return type:

float | None

Example

>>> from shapely.geometry import Point
>>> pt1 = Point(-0.1276474, 51.5073219)
>>> pt2 = Point(-1.9026911, 52.4796992)
>>> calc_distance_on_unit_sphere(pt1, pt2)
162.66049633957005

Note