Latitude given origin longitude, destination coordinates and distance

295 Views Asked by At

Given one origin coordinate (latitude or longitude), destination coordinates (both latitude and longitude) and the distance between both sets of coordinates in km, is it possible to compute the other origin coordinate?

Edit: title updated to reflect that bearing is not known.

1

There are 1 best solutions below

0
On

I assume we treat the Earth as a sphere; the math for an ellipsoid gets much more complicated.

For a given destination point with known latitude and longitude, and a known distance from origin to destination, the origin must be somewhere on the circle whose center is at the destination and whose geodetic radius (distance along the surface from the center to the circumference) is the desired distance. This circle is a small circle unless the geodetic radius is exactly $1/4$ of the circumference of the Earth.

If you know the longitude of the origin, that information places the origin on one half of a particular great circle. (The other half of that great circle has a longitude $180$ degrees different from the desired longitude.) But if you know the latitude of the origin instead, that places the origin on the circle at that latitude (which is a small circle unless it is the equator).

So the origin will have to be at an intersection of the small circle around the destination with either the longitude circle or the latitude circle.

The intersection between two circles is one point if the circles are exactly tangent; two points if they are closer, and no intersection at all if they are farther apart. In the case of a known longitude you also have to ask whether the intersection points are on the half of the great circle at the correct longitude.

Origin at a known latitude

For a known latitude, you can use the haversine distance formula: $$ \operatorname{hav}\left(\Theta\right) = \operatorname{hav}\left(\varphi_2 - \varphi_1\right) + \cos\left(\varphi_1\right)\cos\left(\varphi_2\right)\operatorname{hav}\left(\lambda_2 - \lambda_1\right) $$ where $\phi_1,\lambda_1$ are the latitude and longitude (respectively) of the origin, $\phi_2,\lambda_2$ are the latitude and longitude (respectively) of the destination, and $\Theta = \frac dR$ where $d$ is the geodetic distance from origin to destination and $R$ is the radius of the Earth. You can also use the formula $\operatorname{hav}(\alpha) = \sin^2(\alpha/2).$

You then have an equation in which everything is known except for $\lambda_1,$ which occurs only once. Solve for $\lambda_1.$

For some input values there will be no solution for $\lambda_1,$ indicating that it is not possible to reach the desired destination traveling the desired distance from any point at the desired latitude.

Origin at a known longitude

For a known longitude, identify the great circle on which the line of longitude of the origin lies, and find the point $C$ on that great circle closest to the destination. If $A$ is the destination and $B$ is a geographic pole of the Earth then $ABC$ is a right spherical triangle with right angle at $C.$ For simplicity in explanation let's suppose the destination is in the northern hemisphere and $B$ is the north pole; the same method works in mirror image in the southern hemisphere using the south pole.

Knowing the longitude of the destination you can determine the angle $B$ in the spherical triangle $ABC$; choose angle $B$ so it is no greater than a right angle, even if this means $C$ will be on the "wrong half" of the great circle. Let $\gamma$ be the angle between $A$ and $B$; this is the co-latitude of $A$, easily found be subtracting the destination latitude from a right angle.

You can now apply the right spherical trigonometric identity $$ \sin(B) = \frac{\sin(\beta)}{\sin(\gamma)} $$ where $\beta$ is the angular distance from $A$ to $C$. You know $B$ and $\gamma$; solve for $\sin(\beta).$ The spherical law of cosines then says that $$ \cos(\gamma) = \cos(\alpha)\cos(\beta) $$ where $\alpha$ is the distance between $B$ and $C$. You know $\gamma$ and $\sin(\beta)$; find $\cos(\beta)$ and solve for $\alpha.$

Knowing $\alpha,$ you know the latitude of $C.$

Now let $\gamma' = \frac dR$ where $d$ is the desired distance between origin and destination and $R$ is the radius of the Earth. Then you can define a spherical right triangle $AB'C$ with right angle at $C$, where $B'$ is the desired origin point and $\gamma$ is the angular distance between $A$ and $B'$. If $\alpha'$ is the angular distance between $B'$ and $C,$ the spherical law of cosines says that $$ \cos(\gamma') = \cos(\alpha')\cos(\beta). $$ You know $\gamma$ and $\sin(\beta)$; find $\cos(\beta)$ and solve for $\alpha'.$

Starting at the (now known) point $C$ on the great circle of the longitude of the origin point, travel an angle $\alpha'$ around the circle. Do this once in each direction to find two candidates for the point $B'.$ (Usually this means adding or subtracting $\alpha'$ from the latitude of $C$, but you have to do some extra arithmetic if the path crosses a pole.)

If either of your candidates for $B'$ is on the half of the great circle that has the desired longitude of the origin, it is a possible origin point.

You may find that at some point during this algorithm you are unable to solve for the next required step, in which case you know it is not possible to reach the desired destination traveling the desired distance from any point at the desired longitude.