nathanrooy / spatial-analysis

A collection of algorithms I use for the analysis of geospatial data. Written in C, wrapped in Python.
GNU General Public License v3.0
22 stars 12 forks source link

[Bug] Error in Vincenty Distance Code. Latitude and Longitude Inverted #1

Closed MurrayData closed 5 years ago

MurrayData commented 5 years ago

There is an error in the Vincenty Distance Calculation.

Looking at the Formula https://en.wikipedia.org/wiki/Vincenty's_formulae

Lambda is Longitude, Phi is Latitude

In the code these are the wrong way round.

If you change the lines as follows:

        L_1,phi_1=coord1                       # (lon=L_?,lat=phi_?)
        L_2,phi_2=coord2

It works fine and I've checked it against the online calculator here https://geographiclib.sourceforge.io/cgi-bin/GeodSolve

and Haversine distance from several spatial libraries.

nathanrooy commented 5 years ago

Thank you. This has been fixed.