Member-only story

Haversine formula in Oracle SQL

Johan Louwers

--

Haversine Vs Vincenty debate

When calculating the distance between two point on earth you have choice between Haversine and Vincenty. The Haversine and Vincenty formulas are both used to calculate distances between two points on the Earth’s surface, typically given their latitude and longitude coordinates. However, there are some key differences between the two:

  • Accuracy:
    — Haversine Formula: The Haversine formula provides a relatively simple and straightforward method for calculating distances. While it offers reasonable accuracy for short distances or rough estimates, it may not be as precise for long distances or near-polar regions.
    — Vincenty Formula: The Vincenty formula, also known as the Vincenty’s inverse formula, is more complex and computationally intensive. It accounts for the Earth’s oblate spheroid shape and variations in its curvature, resulting in higher accuracy, particularly for long distances and locations near the poles.
  • Algorithm Complexity:
    — Haversine Formula: The Haversine formula involves basic trigonometric functions such as sine, cosine, and arccosine. It’s relatively straightforward to implement and computationally efficient.
    — Vincenty Formula: Vincenty’s formula requires more complex mathematical calculations, including iterative algorithms to converge on the solution. As a result, it may be slower and more resource-intensive compared to the Haversine formula.
  • Use Cases:
    — Haversine Formula: The Haversine formula is commonly used in applications where a simple and quick distance approximation is sufficient, such as basic mapping, geocoding, or distance-based filtering.
    — Vincenty Formula: The Vincenty formula is preferred for applications that require higher accuracy over long distances, such as geodesic surveying, GPS navigation, or geodetic calculations in scientific research and engineering projects.

In summary, while both the Haversine and Vincenty formulas serve the purpose of calculating distances between geographic points, the choice between them depends on the level of accuracy required and the computational resources available for the task at hand.

In this post, we will utilize the Haversine formula to compute distances between weather observation stations operated by the Royal Netherlands Meteorological Institute (KNMI). In the example outlined below…

--

--

No responses yet