Henk Schreij (2/17/2009)
Please could you supply us a "km version" of this nice script.
In Europe, Australia, Asia, etc. we don't use miles or feet. 😉
Then how do you walk? 😛 Heh, just kidding...
You make an excellent point, like most folks who have spent their whole life in the USA, I sometimes forget that everyone else uses metric. Anyway, the key to this rescaling (and the others requested) is the factor that appears on the first line, right before the "acos(": 3963.0. This is the radius (maximum) of the Earth in miles. If you want it in kilometers, just change this number to the radius of the earth in kilometers (6378 max, 6357 avg):
Create Function LatLonDistKM(
) Returns Float
Faster way to calculate distance in kilometers using Latitude & Longitude.
This is accurate in KM to about 4.5 decimal places, except for very small distances.
NOTE: 57.295779513082323 = 180.0 / PI
(converts Lat/Lon degrees to spherical radians)
Ref: The formula is derived from the Spherical Law of Cosines,
, KM: 17-Feb-2009