scipy / scipy

SciPy library main repository
https://scipy.org
BSD 3-Clause "New" or "Revised" License
13.12k stars 5.2k forks source link

ENH: Add great-circle distance to list of supported metrics in `scipy.spatial.distance` #21806

Open TheoMathurin opened 2 weeks ago

TheoMathurin commented 2 weeks ago

Is your feature request related to a problem? Please describe.

There are many use cases where the relevant metric is the great-circle distance given by the haversine formula (see here), e.g. when dealing with geolocated points.

Describe the solution you'd like.

Simply adding 'haversine' to the list of supported metrics.

Describe alternatives you've considered.

Up until now I've always computed it myself.

Additional context (e.g. screenshots, GIFs)

I would be interested in submitting a PR.

Related to https://github.com/scipy/scipy/issues/21594

tylerjereddy commented 2 weeks ago

I'll just add the usual note that similar great circle distance math should be happening under the hood for geometric_slerp and SphericalVoronoi IIRC, though we may have used an approach other than haversine.