1
votes

I have two given lat and lon points. For example, lets assume I have two positions (point_1 and point_2) at coordinates (lat1, lon1) and (lat2, lon2). I would like to calculate a third point, that is on the same latitude as that of point_2, but x km to the east or west of point_2. So the third point will have the same latitude as point_2, but a different longitude depending on distance x (in kilometers), in other words point_3 will be (lat2, lon?). I am writing this in IDL, but any other language or formulas would be very welcome.

Thanks

2
This problem is solvable with some trigonometrics and basic maths. Sure you can't figure out?svens
It is not clear to me what point one has to do with it...? As per your question, you are just looking for a position x ml west or east of point 2. Is that correct....?KristoferA
Is the coordinate in degrees:minutes:seconds or decimal degrees?James Goodwin
This gentleman has provided all you need as C# code in his blog: bryan.reynoldslive.com/post/…KristoferA

2 Answers

1
votes

You don't use point 1 anywhere, do you? Let's say our point is P = (lat, lon)

The first rule of problems like this: draw a picture! From a cross-section of the earth, you can see that the radius of the circle centered on the earth's axis, going through your two points, is R*cos(lat). (R is the earth's radius. I hope you don't need to consider the earth an ellipsoid here.) The length x therefore takes up an angle (in degrees) of 360*x/(2*pi*R*cos(lat)). The new point you want is then:

P' = ( lat, lon +- 180*x/(2Rcos(lat)) )

I'm assuming you're using -180 to 0 for west longitude, so you have +/- for east/west. You'll have to check if you need to wrap around. Pseudo-code:

if (lon < -180)
   lon += 360
else if (long > 180)
   lon -= 360

Just for fun: if you do care about the earth being ellipsoidal, the radius of the circle is (instead of R*cos(lat)):

1/sqrt(tan^2 lat / Rp^2 + 1 / Re^2)

where Rp is the polar radius and Re is the equatorial radius. If Rp = Re, this reduces to the original formula, since 1 + tan^2 lat = sec^2 lat

0
votes
import math

R = 6378.1 #Radius of the Earth
brng = 1.57 #Bearing is 90 degrees converted to radians.
d = 15 #Distance in km

#lat2  52.20444 - the lat result I'm hoping for
#lon2  0.36056 - the long result I'm hoping for.

lat1 = math.radians(52.20472) #Current lat point converted to radians
lon1 = math.radians(0.14056) #Current long point converted to radians

lat2 = math.asin( math.sin(lat1)*math.cos(d/R) +
     math.cos(lat1)*math.sin(d/R)*math.cos(brng))

lon2 = lon1 + math.atan2(math.sin(brng)*math.sin(d/R)*math.cos(lat1),
             math.cos(d/R)-math.sin(lat1)*math.sin(lat2))

lat2 = math.degrees(lat2)
lon2 = math.degrees(lon2)

print(lat2)
print(lon2)