Haversine formula in Oracle SQL
5 min readApr 5, 2024
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.