Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Haversine distance may be using the wrong phi1 and phi2 angle #11308

Open
lucasalavapena opened this issue Feb 26, 2024 · 2 comments · May be fixed by #11648
Open

Haversine distance may be using the wrong phi1 and phi2 angle #11308

lucasalavapena opened this issue Feb 26, 2024 · 2 comments · May be fixed by #11648
Labels

Comments

@lucasalavapena
Copy link

Repository commit

2e405f3

Python version (python --version)

NA

Dependencies version (pip freeze)

NA

Expected behavior

First of thanks for all the algorithms and the work!

The current (and initial) implementation of the haversine distance is using reduced latitudes (as one does for Lambert's formula see https://en.wikipedia.org/wiki/Geographical_distance#Lambert's_formula_for_long_lines), however, from my understanding the haversine distance should be using the raw latitudes (in radians like the longitudes are currently being handled). At least that is how it is written in https://en.wikipedia.org/wiki/Haversine_formula#Formulation .

The haversine distance from my understanding is supposed to work on a sphere, however, the notion on reduced latitude and flattening factors exist to deal with the non-spherical nature of the Earth (see https://en.wikipedia.org/wiki/Flattening). I am by no means an expert, I could very well be wrong.

Moreover, reading the wikipage and other implementations the transformation to a reduced latitude is not needed for the haversine distance, the latitude is used directly. Here are some references:

additional implementations:

I think most likely there was some confusion with Lambert's formula.

I am happy to make a small PR, if there is an agreement with my observation.

Actual behavior

Use the right angles and the results should slightly be different. I did some test, it is not that significant.

@Maanit491
Copy link

The issue is resolved by me, please review my PR :)

@Maanit491
Copy link

Kindly review my PR @lucasalavapena

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants