xrspatial.proximity.great_circle_distance#

xrspatial.proximity.great_circle_distance(x1: float, x2: float, y1: float, y2: float, radius: float = 6378137) float[source]#

Calculates great-circle (orthodromic/spherical) distance between (x1, y1) and (x2, y2), assuming each point is a longitude, latitude pair.

Parameters
  • x1 (float) – x-coordinate (latitude) between -180 and 180 of the first point.

  • x2 (float) – x-coordinate (latitude) between -180 and 180 of the second point.

  • y1 (float) – y-coordinate (longitude) between -90 and 90 of the first point.

  • y2 (float) – y-coordinate (longitude) between -90 and 90 of the second point.

  • radius (float, default=6378137) – Radius of sphere (earth).

Returns

distance – Great-Circle distance between two points.

Return type

float

References

Examples

>>> from xrspatial import great_circle_distance
>>> point_a = (123.2, 82.32)
>>> point_b = (178.0, 65.09)
>>> # Calculate Great Circle Distance
>>> dist = great_circle_distance(
...     point_a[0],
...     point_b[0],
...     point_a[1],
...     point_b[1])
>>> print(dist)
2378290.489801402