fips.metrics.haversine_matrix#

fips.metrics.haversine_matrix(lats, lons, earth_radius=None, deg=True)[source]#

Calculate the pairwise Haversine distance matrix between a set of coordinates.

Parameters:
  • lats (array-like) – 1D array-like of latitude coordinates in degrees (if deg=True) else in radians.

  • lons (array-like) – 1D array-like of longitude coordinates in degrees (if deg=True) else in radians.

  • earth_radius (float, optional) – Radius of the Earth in kilometers, by default 6371.0 km.

  • deg (bool, optional) – If True, input coordinates are in degrees and will be converted to radians. If False, input coordinates are assumed to be in radians, by default True.

Returns:

A 2D NumPy array (matrix) where the element at (i, j) is the Haversine distance between the i-th and j-th coordinate. The diagonal of the matrix will be zero.

Return type:

np.ndarray