Skip to main content

HAVERSINE

Introduced or updated: v1.2.555

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 degrees.

Syntax

HAVERSINE(<lat1>, <lon1>, <lat2>, <lon2>)

Arguments

ArgumentsDescription
<lat1>The latitude of the first point.
<lon1>The longitude of the first point.
<lat2>The latitude of the second point.
<lon2>The longitude of the second point.

Return Type

Double.

Examples

SELECT
HAVERSINE(40.7127, -74.0059, 34.0500, -118.2500) AS distance

┌────────────────┐
│ distance │
├────────────────┤
3936.390533556
└────────────────┘
Try Databend Cloud for FREE

Multimodal, object-storage-native warehouse for BI, vectors, search, and geo.

Snowflake-compatible SQL with automatic scaling.

Sign up and get $200 in credits.

Try it today