Using Haversine formula to solve for a single coordinate X miles away

$\begingroup$

I am using the Haversine formula to calculate a distance in miles between two (lat, lng) coordinate pairs. (Note: I am aware and okay with limitations in the formula related to the non-spheroidal (ellipsoidal) shape of the Earth.)

I would like to use this formula to solve for either a single latitude or single longitude that is due north, east, west, or south of a given coordinate. This is maybe best illustrated through a diagram; I have the central red point as given and am trying to solve for the 4 outer red points below:

enter image description here

From the central coordinate of (38.0, -77.0), I want to solve (individually) for the 4 missing points at each side of the circle pictured, assuming a distance of 5 miles. So in each equation, I am given a distance and 3 coordinates, and want to solve for the 4th coordinate.

How can I rework Haversine formula to solve for an individual coordinate given the other 3?

What I have tried is to use sympy, but the calculation seems to time out, unless I have a symbol wrong somewhere. I've also tried to invert the formula, but have gotten stuck halfway.

To use the top point (lat2, -77.0) as an example, I'm given the formulas

dlon = lon2 - lon1
dlat = lat2 - lat1
a = (sin(dlat/2))^2 + cos(lat1) * cos(lat2) * (sin(dlon/2))^2
c = 2 * atan2( sqrt(a), sqrt(1-a) )
d = R * c (where R is the radius of the Earth)
lat1 = radians(38.0)
lon1 = radians(-77.0)
lon2 = radians(-77.0)
d = 5.0

And want to solve for lat2.

$\endgroup$

2 Answers

$\begingroup$

Let's start from the formula:$$d=2R\arcsin\sqrt{\sin^2\frac{\phi_2-\phi_1}{2}+\cos\phi_1\cos\phi_2\sin^2\frac{\lambda_2-\lambda_1}{2}}$$So if the longitudes are the same, $\lambda_1=\lambda_2$, then the formula reduces to $$d=R|\phi_2-\phi_1|$$so $$\phi_2=\phi_1\pm\frac dR$$You need to check if $\phi_2$ is reasonable (see circles with radii greater than the distance to the poles).

Similarly, to check points at the same latitude, $\phi_1=\phi_2$,$$d=2R\arcsin\left|\cos\phi_1\sin\frac{\lambda_2-\lambda_1}2\right|$$From here$$\sin\frac{\lambda_2-\lambda_1}2=\pm\frac1{\cos\phi_1}\sin\frac d{2R}$$This is once again a simple way to get $\lambda_2$, as long as the magnitude of the right hand side is less than $1$. So careful with large distances and around the poles.

$\endgroup$ 2 $\begingroup$

The reason you cannot find a formula for determining such a point is that the point may not exist.

Consider walking, say, 1000 feet south from the north pole along the Greenwich meridian. You're at longitude 0, latitude 89.99...

Your circle of latitude is about 6000 feet long --- just a little over a mile. There's no point on that circle for which the haversine formula will return a distance of $5$ miles. So if you want a point "due east" by 5 miles, there is no such thing (at least if distance is determined by the haversine formula).

It's interesting (to me at least) that at a point just about 2.5 miles from the pole, the "east" and "west" points that you're seeking actually coincide, and very nearly coincide with the only rational choice for a "north" point (except that its longitude will differ from yours by 180 degrees).

$\endgroup$ 4

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

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

You Might Also Like