This query function will calculate the distance, in meters,
between two geographical coordinates
(lat1
,
lon1
) and
(lat2
,
lon2
) along an ideal earth
surface.
It uses the Haversine approximation, which is accurate to about 0.5%. It does not take the altitude into account.
Parameter | Type | Required | Default Value | Description |
---|---|---|---|---|
as | string | optional[a] | _distance | The name of the field that is produced by the function. |
lat1 | string | required | The field to use for latitude of first point. | |
lat2 | string | required | The field to use for latitude of second point. | |
lon1 | string | required | The field to use for longitude of first point. | |
lon2 | string | required | The field to use for longitude of second point. | |
[a] Optional parameters use their default value unless explicitly set. |
Note
The values of latititude and longitude coordinates must be expressed in decimal degrees.
geography:distance()
Examples
Click
next to an example below to get the full details.Calculate Distance Between Geographical Coordinates
Calculate the distance between two geographical coordinates using the geography:distance()
function