pyufunc.calc_distance_on_unit_haversine#
- pyufunc.calc_distance_on_unit_haversine(lon1, lat1, lon2, lat2, unit='km')#
Calculate the great-circle distance between multiple pairs of points on the Earth’s surface specified in decimal degrees using the Haversine formula.
- Parameters:
lon1 (np.ndarray) – the longitudes of the first points
lat1 (np.ndarray) – the latitudes of the first points
lon2 (np.ndarray) – the longitudes of the second points
lat2 (np.ndarray) – the latitudes of the second points
unit (str, optional) – the unit for the distance (‘meter’, ‘km’, ‘mile’). Defaults to “km”.
- Returns:
an array of distances between each pair of points.
- Return type:
np.ndarray
Example
>>> import numpy as np >>> lon1 = np.array([-0.1276474, -0.1276474]) >>> lat1 = np.array([51.5073219, 51.5073219]) >>> lon2 = np.array([-1.9026911, -1.9026911]) >>> lat2 = np.array([52.4796992, 52.4796992]) >>> calc_distance_on_unit_haversine(lon1, lat1, lon2, lat2) array([162.66049634, 162.66049634])
- Returns:
A numpy array of distances between each pair of points.