Haversine Formula: Estimating Distance Between Two GPS Points
A practical explanation of the Haversine formula, its assumptions and why coordinate-based distance remains an estimate.
The Haversine formula estimates the great-circle distance between two latitude/longitude points on a spherical Earth. It is widely used for simple geographic calculations because it is relatively straightforward and numerically well behaved for many ordinary distances. It calculates distance between the points, not the actual path travelled between them.
What the formula represents
The formula converts latitude and longitude differences into an angular separation and multiplies by an assumed Earth radius. Its output is the shortest surface distance along a great circle between the two points. A road, walking trail or river route may be longer because it bends around obstacles and follows a network.
Why it is not a route by itself
If a tracker has ten coordinate samples, it can sum the distance between consecutive samples. The result depends on how frequently points arrive and how accurate they are. Sparse points can cut across corners, while noisy points can add false zigzags. The formula cannot infer a missing road or remove every GPS error on its own.
Spherical approximation and practical accuracy
Earth is not a perfect sphere, so higher-precision geodesy may use ellipsoidal calculations. For casual trip estimates, the spherical approximation may be adequate, but the input coordinates usually dominate the error in a phone browser scenario. A mathematically correct formula cannot turn uncertain location fixes into certified measurements.
How to validate an implementation
Use known test points and check that identical points return approximately zero, and that a short known separation produces a plausible distance. Test unit conversions separately. Also inspect behavior when coordinates are missing, invalid or duplicated. A formula test verifies the calculation, not the GPS receiver's real-world accuracy.
Frequently asked questions
Does Haversine measure the road route?
No. It measures great-circle distance between points; a tracker can sum segments, which still approximates the route.
Can Haversine fix GPS drift?
No. It calculates distance from the coordinates it receives and cannot remove inaccurate input by itself.
Technical references
These references explain the underlying browser and positioning concepts. They do not imply endorsement of this website.