How to Calculate Distance Between Decimal Degree Coordinates

coordinatesdistance

I have coordinates in decimal degrees e.g: point A:Lat,Lng(5.317101667,-2.023303333) and point B:lat,lng(5.317093333,-2.023318333). The altitude in Meters at Point A is 11m and the altitude and Point B is 33m, How can i accurately calculate the distance between these points? Note I know about Haversine, howeve,r these points are close to each other and I want an accurate way to calculate the distance between these two, would finding the distance between the points with d=sqrt(x2-x1)^2+(y2-y1)^2+(Z2-Z1)^2, be accurate? if so what units would the answer be in? I am looking to get the answer in metres.

Best Answer

Haversine is used for the great circle distance (shortest distance following the sphere curvature). So it does not take the height into account.

For straight line distance, I would first convert your lat/long/radius+alt triplets to XYZ in a 3D cartesian system (see here). Then you can apply your equation.

Because your points are very close from each other, you could also change you coordinates to a projected coordinate system, then you can use your equation for 3D distance with all units in meters. For an exact solution, you should select an custom azimuthal equidistant projection centered on one of your points.

Note : because you are near the equator, you could also use an approximation of the size of a degree (0.5% error if you assume that they are the same in lat and long) in order to compute your distances in meter. 2*pi*R=360degree, so the mean value of a degree along the meridian = 111132 m