LATLNGDISTANCE

The function LATLNGDISTANCE returns the distance between two global positions in miles, kilometers, or nautical miles.

Declaration

LATLNGDISTANCE(latitude1, longitude1, latitude2, longitude2, unit_string) -> distance

Parameters

latitude1 (type: Number)
The latitude of the first position.

longitude1 (type: Number)
The longitude of the first position.

latitude2 (type: Number)
The latitude of the second position.

longitude2 (type: Number)
The longitude of the second position.

unit_string (type: string, default: "m" - miles)
The unit of measurement the result should represent. Valid units are:

  • "k" - kilometers
  • "m" - miles
  • "n" - nautical miles

Return Values

distance (type: Number)
The distance between the two positions in the units specified by the unit_string.

Examples

The distance between the latitude/longitude position (40.7648, -73.9797) and (37.431136, -122.14044) is 2560.1436555900605 miles.

LATLNGDISTANCE(40.7648, -73.9797, 37.431136, -122.14044) -> 2560.1436555900605

The same distance in kilometers is 4120.151831261931

LATLNGDISTANCE(40.7648, -73.9797, 37.431136, -122.14044, "k") -> 4120.151831261931