latlongdistance(

LATITUDE1

,

LONGITUDE1

,

LATITUDE2

,

LONGITUDE2

,

UNITS/RADIUS

)

The** latlongdistance( **function calculates the distance between two points on the earth (or any other sphere).

**Parameters**

This function has five parameters:

*latitude1* – the latitude of the first point, expressed in decimal degrees (for example 34.1614).

*longitude1* – the longitude of the first point, expressed in decimal degrees (for example -118.0054).

*latitude2* – the latitude of the second point.

*longitude2* – the longitude of the second point.

*units/radius* – the units for this calculation. This parameter is optional – if omitted, the default is miles. The distance can be calulated in *miles*, *kilometers* or *nautical miles* (and the abbreviations *mile*, *kilo*, *km* and *nm* are also accepted). This parameter can also be used to spedify the radius of the earth or any other sphere.

**Description**

This function calculates the distance between two points on the earth (or any other sphere). The points `34,-118`

and `35,-118`

are about 69 miles apart.

`latlongdistance(34,-118,35,-118) ☞ `*69.097585*

The distance is normally calculated in miles, but you can also specify kilometers or nautical miles.

`latlongdistance(34,-118,35,-118,"miles") ☞ `*69.097585*
latlongdistance(34,-118,35,-118,"kilometers") ☞ *111.194927*
latlongdistance(34,-118,35,-118,"nm") ☞ *60.039326.*

The final parameter can also be used to specify the radius of the earch (or other sphere). In that case, the units can be whatever you want – the results will be in the same units. This example calculates a distance between two objects on the earth in meters (as noted below, this calculation isn’t really accurate to the meter, much less a fraction of a millimeter).

`latlongdistance(34,-118,35,-118,6378100) ☞ `*111318.845021*

This example calculates a distance on the moon in kilometers (the radius of the moon is 1,737 km).

`latlongdistance(-118,34,-118,35,1737) ☞ `*30.316369*

#### Accuracy

This function uses the Haversine formula to calculate distances, which is well conditioned for all distances except for those close to 180° (see Great Circle Distance). The function does assume that the Earth is a perfect sphere.

**See Also**

**History**

10.0 | New | New in this version. |