HAVERSINE

functionsupportedCore SQL functions

docs.snowflake.com ↗

Geospatial functions

Calculates 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

NameRequiredDescription
lat1requiredThe latitude of the first point in decimal degrees.
lon1requiredThe longitude of the first point in decimal degrees.
lat2requiredThe latitude of the second point in decimal degrees.
lon2requiredThe longitude of the second point in decimal degrees.

Returns

This function returns a value of type FLOAT.