GEODISTANCE_HAVERSINE Function

Computes the distance between two geographical points. This formula provides greater accuracy, particularly for shorter distances.

Category: Information and Conversion
Note: This function provides better accuracy than the GEODISTANCE_COSINE function, but is slower.

Syntax

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

Arguments

lat1

latitude for first location, in decimal degrees. South latitudes are negative

lon1

longitude for first location, in decimal degrees. East longitudes are positive

lat2

latitude for second location, in decimal degrees. South latitudes are negative

lon2

longitude for second location, in decimal degrees. East longitudes are positive

Details

The geodistance_haversine function is used to is used to compute the distance between two geographical points.

Note: Each point is represented using latitude and longitude in decimal degrees. South latitudes are negative and east longitudes are positive. The function returns -1 when there is an error.

Example

geodistance_haversine(21.349017, -45.566906, -35.203839, 19.996602)