Reputation: 11
I want to know the calculation formula with the help of GPS Coordinates for shortest distance calculation with accuracy >= 5 mtr.
I have checked the Haversine Formula and the Great circle distance formula. But they are good for long distance calculations. If we talk about accuracy in mtrs which formula should be used?
Upvotes: 1
Views: 2082
Reputation: 169833
Vincenty's formulae are accurate up to millimeter scale on the WGS84 approximation of earth's shape (which will be overkill as obviously, earth does not agree with WGS84 to that degree).
A few years ago, I implemented some algorithms for distance calculation in Javascript. Feel free to ask if you have any questions about the algorithms as the code lacks comments.
One potential problem is that these algorithms work at sea-level and do not take height differences into account. It might be a better idea to convert to geocentrical cartesian coordinates instead and use the straight-line distance instead...
The direct expression for the straight-line distance d
of points with longitude φ
, latitude λ
and height h
is given by
k = √(a²·cos²φ + b²·sin²φ)
r = (a²/k + h)·cosφ
z = (b²/k + h)·sinφ
d = √((z - z')² + r² + r'² - 2·r·r'·cos(λ - λ'))
with the following values for the paramteres
a = 6378137m
b = (a·297.257223563)/298.257223563
Upvotes: 6
Reputation: 12457
If (long0, lat0) is one point and (long1, lat1) the other:
For small distances you can use:
x0 = long0 * r_earth * cos(lat0)
y0 = lat0 * r_earth
x1 = long1 * r_earth * cos(lat1)
y1 = lat1 * r_earth
dx = x0 - x1
dy = y0 - y1
d = sqrt(dx*dx + dy*dy)
long
= longitude in radians
lat
= latitude in radians
r_earth
= radius of the earth
You can further simplify this formula by factoring out r_earth
and/or by assuming cos(lat0)==cos(lat1).
Upvotes: 2