clouddrift.pairs.pair_space_distance#
- clouddrift.pairs.pair_space_distance(lon1: list[float] | ndarray[float] | Series | DataArray, lat1: list[float] | ndarray[float] | Series | DataArray, lon2: list[float] | ndarray[float] | Series | DataArray, lat2: list[float] | ndarray[float] | Series | DataArray) ndarray[float] [source]#
Given two arrays of longitudes and latitudes, return the distance on a sphere between all pairs of points.
Parameters#
- lon1array_like
First array of longitudes in degrees.
- lat1array_like
First array of latitudes in degrees.
- lon2array_like
Second array of longitudes in degrees.
- lat2array_like
Second array of latitudes in degrees.
Returns#
- distancenp.ndarray[float]
Array of distances between all pairs of points.
Examples#
>>> lon1 = [0, 0, 1, 1] >>> lat1 = [0, 0, 1, 1] >>> lon2 = [1, 1, 2, 2] >>> lat2 = [1, 1, 2, 2] >>> pair_space_distance(lon1, lat1, lon2, lat2) array([[157424.62387233, 157424.62387233, 0. , 0. ], [157424.62387233, 157424.62387233, 0. , 0. ], [314825.26360286, 314825.26360286, 157400.64794884, 157400.64794884], [314825.26360286, 314825.26360286, 157400.64794884, 157400.64794884]])