Distance

The Distance function calculates the minimum distance between two geographies, in specified units.

๐Ÿ“˜

This function isn't compatible with all data platform connections. To check if your connection supports it, see Supported data platforms and feature compatibility.

Syntax

Distance(units, geog1, geog2)

The function arguments are:

units
Required
The unit of measurement for the distance.
Valid values are "kilometers", "meters", and "miles".
geog1
Required
First geography of the pair between which we calculate the distance.
Must be in valid Geography format.
To work from known latitude and longitude values, use the MakePoint or MakeLine functions.
geog2
Required
Second geography of the pair between which we calculate the distance.
Must be in valid Geography format.
To work from known latitude and longitude values, use the MakePoint or MakeLine functions.

Examples

Distance("kilometers", [Coordinates], MakePoint(0, 0))
Distance("miles", [Coordinates], MakePoint(0, 0))

The Distance function returns the following values for the Coordinates column, when specifying distance in either kilometers or miles from coordinates (0, 0):

Example of the Distance function, showing the distance in kilometers and miles from a set of coordinates to the origin
๐Ÿšฉ

On Databricks connections, values might differ slightly from those shown in the examples. This is because Databricks represents earth using the WGS 84 ellipsoid, while other connections assume a perfect sphere.