Function: GeoDistance
Description
Returns the distance between two points on a sphere given their longitudes and latitudes. This function uses the haversine formula to compute for the distance.
The calculation assumes the earth's radius to be 3958.7613 miles / 6371.0088 kilometers.
Syntax
GeoDistance(lat1,long1,lat2,long2[,use_metric])
Arguments
lat1, long1 is the first point, and must be a valid latitude and longitude pair specified in degrees
lat2, long2 is the second point, and must be a valid latitude and longitude pair specified in degrees
use_metric is an optional parameter. If this is included, the distance returned is in kilometers. Otherwise the distance returned is in miles.
Return value
This function returns a distance in value, expressed in kilometers or miles as specified using the use_metric parameter.
Calculated field example
To calculate the geodistance between Adelaide, Australia (34°55'S 138°35'E) and New York City (40°43'N 74°00'W) use the formula: GeoDistance(34.55,138.35,40.43,74.00)
The function returns: 3473.27994889404