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
Wikipedia: https://en.wikipedia.org/wiki/Great-circle_distance#:~:text=The%20great%2Dcircle%20distance%2C%20orthodromic,line%20through%20the%20sphere’s%20interior). # noqa
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