Skip to main content

Categories: Geospatial

GEO_DISTANCE

Returns the distance between two geographic points in meters, calculated using the Haversine formula.

Syntax​

GEO_DISTANCE(lat1 float, lon1 float, lat2 float, lon2 float) → double​

  • lat1: Latitude of the first point in degrees.
  • lon1: Longitude of the first point in degrees.
  • lat2: Latitude of the second point in degrees.
  • lon2: Longitude of the second point in degrees.

Examples

Determine the distance from Venice, Italy to Paris, France in meters
SELECT GEO_DISTANCE(45.4408, 12.3155, 48.8566, 2.3522)
-- 842876.0300143223
Calculate the distance between two identical points
SELECT GEO_DISTANCE(0, 0, 0, 0)
-- 0.0

Usage Notes​

The parameters to this function can only be the FLOAT data type. You must CAST other data types to FLOAT. This function calculates the result using the Haversine distance algorithm.