trajminer.utils.distance.haversine

class trajminer.utils.distance.haversine

Computes the haversine distance between two pairs of latitude and longitude.

xarray-like, shape (2)

An array like [lat, lon]. lat and lon must be floats.

yarray-like, shape (2)

An array like [lat, lon]. lat and lon must be floats.

unitstr (default=’meters’)

The unit to use for measuring the distance. It must be one of {‘meters’, ‘km’, ‘mi’}.

distancefloat

The haversine distance between x and y in the specified unit.

>>> from trajminer.utils.distance import haversine
>>> haversine([-27.601759, -48.5208], [-27.6894608,-48.4848])
10376.68536590766
>>> haversine([-27.601759, -48.5208], [-27.6894608,-48.4848], unit='km')
10.37668536590766
>>> haversine([-27.601759, -48.5208], [-27.6894608,-48.4848], unit='mi')
6.447789383168045
__init__(**kwargs)

Initialize self. See help(type(self)) for accurate signature.