Calculating Bearings With Two Sets of Lat/Long Coordinates

edt4444

New Member
Joined
Nov 6, 2015
Messages
5
I have a list of locations with corresponding lat/long coordinates and am trying to calculate initial bearings between two locations. The formula I am using is:

=IF(ROUND(DEGREES(ATAN2(COS(RADIANS($I2))*SIN(RADIANS($K2))-SIN(RADIANS($I2))*COS(RADIANS($K2))*IF($J2=$H2,$H2,COS(RADIANS($J2-$H2))),IF($J2=$H2,$H2,SIN(RADIANS($J2-$H2)))*COS(RADIANS($K2)))),2)<0,ROUND(DEGREES(ATAN2(COS(RADIANS($I2))*SIN(RADIANS($K2))-SIN(RADIANS($I2))*COS(RADIANS($K2))*IF($J2=$H2,$H2,COS(RADIANS($J2-$H2))),IF($J2=$H2,$H2,SIN(RADIANS($J2-$H2)))*COS(RADIANS($K2)))),2)*-1,ROUND(DEGREES(ATAN2(COS(RADIANS($I2))*SIN(RADIANS($K2))-SIN(RADIANS($I2))*COS(RADIANS($K2))*IF($J2=$H2,$H2,COS(RADIANS($J2-$H2))),IF($J2=$H2,$H2,SIN(RADIANS($J2-$H2)))*COS(RADIANS($K2)))),2))

Column I = Latitude 1, Column H = Longitude 1, Column K = Latitude 2, Column J = Longitude 2

It seems to work in some instances and in other cases does not. For example, when using these coordinates: Lat/Long1 = -86.879036, 33.525203 and Lat/Long2 = -86.1852, 39.70122 it seems the bearing (4.95, N) is correct. However, when using: Lat/Long1 = -86.879036, 33.525203 and Lat/Long2 = -89.864998, 35.01351 the bearing (58.07, ENE) is incorrect. :confused:

Any ideas as to why this formula seems to work sometimes and at other times not?
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
Hi,

I have not looked at the formula, just the data.

-89.864998 degrees is quite close to the South Pole. If it ever reaches -90 degrees then every direction will be North.
 
Upvote 0
Where did you get your formula?

Based on some simple examples, it doesn't seem to produce reasonable results.

Based on a Dr. Math formula: Math Forum - Ask Dr. Math

I have coded an alternative:

You E2: =IF(ROUND(DEGREES(ATAN2(COS(RADIANS(B2))*SIN(RADIANS(D2))-SIN(RADIANS(B2))*COS(RADIANS(D2))*IF(C2=A2,A2,COS(RADIANS(C2-A2))),IF(C2=A2,A2,SIN(RADIANS(C2-A2)))*COS(RADIANS(D2)))),2)<0,ROUND(DEGREES(ATAN2(COS(RADIANS(B2))*SIN(RADIANS(D2))-SIN(RADIANS(B2))*COS(RADIANS(D2))*IF(C2=A2,A2,COS(RADIANS(C2-A2))),IF(C2=A2,A2,SIN(RADIANS(C2-A2)))*COS(RADIANS(D2)))),2)*-1,ROUND(DEGREES(ATAN2(COS(RADIANS(B2))*SIN(RADIANS(D2))-SIN(RADIANS(B2))*COS(RADIANS(D2))*IF(C2=A2,A2,COS(RADIANS(C2-A2))),IF(C2=A2,A2,SIN(RADIANS(C2-A2)))*COS(RADIANS(D2)))),2))

Me F2: =MOD(ATAN2(COS(RADIANS(A2))*SIN(RADIANS(C2))-SIN(RADIANS(A2))*COS(RADIANS(C2))*COS(RADIANS(D2-B2)),COS(RADIANS(C2))*SIN(RADIANS(D2-B2)))*180/PI(),360)

I haven't tested exhaustively and can't guarantee that the formula is correct, but the results at least seem reasonable?
PS - I get 31.4 and 179.9 degrees respectively for your two examples.

*ABCDEF
1LAT1LON1LAT2LON2YouMe
210020090.00.0
320010090.0180.0
41060206085.70.0
5101202012094.30.0
610020184.35.4
710020-195.7354.6

<tbody>
</tbody>


Excel tables to the web >> Excel Jeanie HTML 4




 
Upvote 0
Oops, I think I've incorrectly transposed some Lat/Lon numbers using your formula, so some of the "your" results are mis-stated above.

But my comments still stand.
 
Upvote 0
Stephen, I found the formula on another site. It never gave me consistent results, however the formula you have shared seems to be working perfectly! I tested with several sets of coordinates and seem to be getting accurate results.

Thank you very much for your help!
 
Upvote 0

Forum statistics

Threads
1,221,470
Messages
6,160,032
Members
451,611
Latest member
PattiButche

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top