Distance through the Earth

This calculator calculates the distance from one point on the Earth to another point, going through the Earth, instead of going across the surface.

This page exists due to the efforts of the following people:

Timur

Timur

Created: 2018-02-21 21:01:44, Last updated: 2021-02-26 14:11:19

If you want to measure the distance from one point on the Earth to another, you should use the great-circle or orthodromic distance formula. We even have two calculators for this: the one which uses haversine formula, and the another one, which uses Vincenty formula.

However, what if you want to know the distance between two points on the Earth through the Earth, not across the surface? As it turns out, the problem is relatively simple, except for a couple of gotchas. The calculator below finds the distance between two points through the Earth, and the derivation of the formula with all gotchas can be found below the calculator.

PLANETCALC, Distance through the Earth

Distance through the Earth

°
°
°
°
Digits after the decimal point: 3
Distance, km
 

Distance through the Earth

Ok, we have two points on the Earth's surface, defined by their latitude and longitude, and we want to know the distance between them going "through" the Earth instead of around it. Technically, we have spherical coordinates of each point in three-dimensional space because we know the Earth's radius, inclination angle (latitude), and azimuth angle (longitude). If we convert these to cartesian coordinates, with x, y, z in three-dimensional space, we can easily find the distance using the well-known Euclidean distance formula:
D=\sqrt{(x_2 - x_1)^2+(y_2-y_1)^2+(z_2-z_1)^2}

So, let's define our Cartesian coordinate system. Origin will be the center of the Earth. The x-axis will point to zero meridian intersection with the equator plane. The y-axis will point to 90 degrees west meridian intersection with equator plane z-axis will point to the North.

Cartesian coordinate system
Cartesian coordinate system

\phi is our longitude, \theta is our latitude.

Cartesian coordinates can be obtained from spherical coordinates using the following relations:
x=R\, cos \theta \, cos \phi \\ y=R\, cos \theta \, sin \phi \\ z=R\, sin \theta

We're almost done, but we still need to consider a couple of factors, which arise because, in geodesy, the Earth is approximated with oblate spheroid or ellipsoid of revolution. So, when we talk about coordinates, we talk about coordinates on the surface of reference ellipsoid used in the geodetic datum, in this case, WGS 84 (hence, the distance is also measured between two points of reference ellipsoid). The factors are:

Since the Earth is flattened at the poles and bulges at the equator, the Earth radius is not constant and depends on the latitude of the point. Thus, we need to compute it for both points, which can be done with this calculator.

WGS 84 latitude of a point is geodetic latitude, determined by the angle between the equatorial plane and normal to the ellipsoid instead of geocentric latitude, which is determined by the angle between the equatorial plane and line joining the point to the center of the ellipsoid. Since our cartesian system's origin is the center of the Earth, we need to convert geodetic latitude to geocentric latitude for both points.

We account for those using these formulas:
tan(\alpha)=\frac{b}{a}tan(\beta) \\ R =\sqrt{\frac{ (a^2cos(\beta))^2+(b^2sin(\beta))^2}{(a\,cos(\beta))^2+(b\,sin(\beta))^2}},
where \alpha is geocentric latitude, \beta is geodetic latitude, a - semi-major axis of the ellipsoid, b - semi-minor axis of the ellipsoid.

To summarize, to calculate the distance, we should do the following:

  • Calculate Earth radius at each point
  • Calculate geocentric latitude at each point
  • Convert spherical coordinates of each point to cartesian coordinates, from calculated radius, geocentric latitude, and longitude to x,y,z.
  • Calculate distance using Euclidean distance formula
URL copied to clipboard
PLANETCALC, Distance through the Earth

Comments