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 `-118,34`

and `-118,35`

are about 32 miles apart.

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

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

`latlongdistance(-118,34,-118,35,"miles") ☞ `*32.439030*
latlongdistance(-118,34,-118,35,"kilometers") ☞ *52.202339*
latlongdistance(-118,34,-118,35,"nm") ☞ *28.186477*

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(-118,34,-118,35,6378100) ☞ `*52260.515018*

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) ☞ `*14.232532*

#### 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. |