4

I am currently trying to compute the real distance between two 3D points (on a WS84 ellipsoid represensation of our earth), but my knowledge in Geographic Information System is pretty nil (except the fact that I know about using geodesic distance instead of the classic sqrt).

What I use can already compute the geodesic distance between two pair of longitude / latitude, it does not however provide the 3D distance.

So I though about using the classic sqrt distance formula using the result of the geodesic distance and the height, is this approach right ?

I can use either the raw mathematica formula, or one that use the current geodesic distance with the difference of elevation.

Note : I obviously tryed to google it, but I only end up on full of article about building 3D mesh using geodesic distance. So I am wondering also if I am really using the right word when searching for "geodesic distance between 3D points".

I checked this from a post given by the tool that suggest question to check but as it seems it ignores the elevation differences : http://www.movable-type.co.uk/scripts/gis-faq-5.1.html

4
  • So you want to compute the height difference between the two 3D points?. Also, do you want just the mathematical approach (functions) or would you use a special program for that?
    – Moh
    Mar 26, 2018 at 15:27
  • You can use the mathematical method smoothly as it works for spatial coordinates perfectly. Mar 26, 2018 at 15:59
  • Do a search on "geodesic distance including height". Here's a stackoverflow question about it: stackoverflow.com/questions/1108965/…
    – mkennedy
    Mar 26, 2018 at 22:02
  • @User2009 I want to compute the distance between 2 lat/lon/alt points, however the tolls that I use provide 2D geodesic distance, so I need to find a way to incorporate the 3rd dimension.
    – Walfrat
    Mar 27, 2018 at 7:29

1 Answer 1

9

If I understood correctly, by "real distance" you mean the distance along an actual 3D straight line connecting your two points. The term "geodesic" refers to a straight line on the curved ellipsoid surface.

Using the pythagorean theorem with the geodesic length and the height difference would not work, because the geodesic line is curved, it is not a square triangle with straight segments.

To calculate a 3D straight distance from lat/lon/ht, you will first need to convert your points to 3D cartesian coordinates (see formulas below). For modern reference systems like WGS84/ITRF2014, the reference frame is called an ECEF (Earth-Centered, Earth-Fixed). Then you will be able to calculate the distance with the square root method in 3D and get the correct answer. However keep in mind that a straight line in 3D, over long distances, can pass through the Earth, so this calculation is mainly useful for 3D "line of sight" types of problems for generally short distances.

Also, make sure you are using ellipsoidal heights, not altitudes above sea level or geoid level, since this could slightly alter the distances. If you need to convert from geoidal (mean sea level) to ellipsoidal, this tool can be useful.

Let's write the lat, lon, ht of a point as phi, lambda, h. You can find the X, Y, Z coordinates of the point like this :

X = (N(phi)+h) * cos(phi) * cos(lambda)

Y = (N(phi)+h) * cos(phi) * sin(lambda)

Z = ((b^2/a^2) * N(phi) + h) * sin(phi)

Where :

N(phi) = a / sqrt(1-e^2*sin^2 phi)

a = semi-major axis (6,378,137 m)

b = semi-minor axis (6,356,752.314245 m)

e^2 = 1 - (b^2 / a^2)

Then with pythagorean in 3D, we find the distance d:

d = sqrt{(X_2-X_1)^2 + (Y_2-Y_1)^2 + (Z_2-Z_1)^2}
2
  • 1
    Thanks, yes I'm calculating for short range, for longer range I would just ignore the elevation difference.
    – Walfrat
    Apr 10, 2018 at 7:11
  • @Walfrat What is your criteria to decide between a short range and a long range ? Dec 19, 2019 at 19:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.