distance
Great-circle distance between two WGS84 points, in kilometres (haversine formula, mean Earth radius of 6371 km). The Earth is treated as a sphere, so the result can be off by up to about 0.5% compared to an ellipsoidal model — plenty for “how far is it” and radius checks. Near antipodal points the formula loses a little precision (well under a metre).
Available since v3.1.8
Import
Section titled “Import”Signature
Section titled “Signature”Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
lat1 | number | Latitude of the first point, in degrees |
lon1 | number | Longitude of the first point, in degrees |
lat2 | number | Latitude of the second point, in degrees |
lon2 | number | Longitude of the second point, in degrees |
Returns
Section titled “Returns”number — The distance in kilometres
Examples
Section titled “Examples”Distance between two cities
Section titled “Distance between two cities”Great-circle distance in kilometres between two latitude/longitude points.
Zero for the same point
Section titled “Zero for the same point”A point is at distance 0 from itself.
