HAVERSINE
functionsupportedCore SQL functionsCalculates the great-circle distance in kilometers between two points on the Earth’s surface, using the Haversine formula. The two points are specified by their latitude and longitude in decimal degrees. Note Snowflake recommends using the ST_DISTANCE function instead of the HAVERSINE function. The ST_DISTANCE function performs the calculation using values of geospatial types, which enables you to store geospatial data and use the geospatial functions on the data. In addition, join predicates that use the ST_DISTANCE function perform better than join predicates that use the HAVERSINE function.
Syntax
HAVERSINE( <lat1>, <lon1>, <lat2>, <lon2> )
Parameters
| Name | Required | Description |
|---|---|---|
lat1 | required | The latitude of the first point in decimal degrees. |
lon1 | required | The longitude of the first point in decimal degrees. |
lat2 | required | The latitude of the second point in decimal degrees. |
lon2 | required | The longitude of the second point in decimal degrees. |
Returns
This function returns a value of type FLOAT.