Formula to Find Bearing or Heading angle between two points: Latitude Longitude



Formula to Find Bearing or Heading angle between two points: Latitude Longitude

Formula to Find Bearing or Heading angle between two points. Bearing or heading angle is used to define navigation generally in the field of aircraft or marine or Vehicle navigation or while working for land surveying. So what’s the heading or bearing? How we can find bearing between the two points on earth, with the formula? Or How we can find the other point, when one point, actual traveled distance and bearing is given? Let us discuss all this points, followed with the example and experiment with the tool for calculating bearing provided in the post. Bearing angle plays a im

Formula to Find Bearing or Heading angle between two points: Latitude Longitude
Formula to Find Bearing or Heading angle between two points: Latitude Longitude

Bearing can be defined as direction or an angle, between the north-south line of earth or meridian and the line connecting the target and the reference point. While Heading is an angle or direction where you are currently navigating in.  This means to reach a particular destination you need to adjust your heading direction with the bearing. Generally a ‘compass’ is an instrument, which gives you the direction information for navigation. You must refer Haversine distance formula before going through this post.

Calculating Bearing or Heading angle between two points:

So if you are from GIS field or dealing with GIS application, you should know bearing and how to calculate bearing with formula. Let us look on formula and tool for bearing:

  • Let ‘R’ be the radius of Earth,
  • L’ be the longitude,
  • ‘θ’ be latitude,
  • β‘ be Bearing.

Denote point A and B as two different points, where ‘La’ is point A longitude and ‘θa’ is point A latitude, similarly assume for point B. Bearing would be measured from North direction i.e 0° bearing means North, 90° bearing is East, 180° bearing is measured to be South, and 270° to be West.

Note: If bearing is denoted with +ve or –ve initials whose values lies between 0° to 180°, then –ve is denoted for South and West sides.

Formula to find Bearing, when two different points latitude, longitude is given:

Bearing from point A to B, can be calculated as,

β = atan2(X,Y),

where, X and Y are two quantities and can be calculated as:

X = cos θb * sin ∆L

Y = cos θa * sin θb – sin θa * cos θb * cos ∆L

Lets us take an example to calculate bearing between the two different points with the formula:

  • Kansas City: 39.099912, -94.581213
  • St Louis: 38.627089, -90.200203

So X and Y can be calculated as,

X =  cos(38.627089) * sin(4.38101)

X  = 0.05967668696

And

Y = cos(39.099912) * sin(38.627089) – sin(39.099912) * cos(38.627089) * cos(4.38101)

Y = 0.77604737571 * 0.62424902378 – 0.6306746155 * 0.78122541965 * 0.99707812506

 Y = -0.00681261948

***Convert θ into radians***

So as, β = atan2(X,Y) = atan2(0.05967668696, -0.00681261948) = 1.684463062558 radians

convert it into degree

           β = 96.51°

This means, from Kansas City if we move in 96.51° bearing direction, we will reach St Louis.

You can also check video explanation of bearing angle.

Tool to find bearing angle between two lat lon points:

Formula to find a lat lon point, when bearing, distance and another lat lon is given

Let us assume a condition, where you want to find out the where will an Airplane will land up, if you have following details of that Airplane, i.e actual distance it will travel, the bearing and the starting point (lat,lon)?

  • Let first point latitude be la1,
  • longitude as lo1,
  • d be distance,
  • R as radius of Earth,
  • Ad be the angular distance i.e d/R and
  • θ be the bearing,

Here is the formula to find the second point, when first point, bearing and distance is known:

  • latitude of second point = la2 =  asin(sin la1 * cos Ad  + cos la1 * sin Ad * cos θ), and
  • longitude  of second point = lo2 = lo1 + atan2(sin θ * sin Ad * cos la1 , cos Ad – sin la1 * sin la2)

You may find both the tool on separate page, with Google map working on it: (It will be update in 2 days, please visit us again)

  • Tool to Find Bearing, when two points are given
  • Tool to find other point, when bearing, distance and one of the point is given.

I hope this article will definitely help you, to find the bearing or heading. You are free to share more data related to bearing or any thing that you uses to calculate bearing and how you use navigation with bearing.

If you find anything difficulty to understand the bearing calculation, you may comment below, so that we will discuss further on finding bearing or heading angle.

Try IGIS Map Tool for GIS Operation

Now we are on Youtube also. Please Like, Share and Subscribe our Channel IGIS Map

Author: Akshay Upadhyay

Owner and Director of a Private Limited company which serves individual to large scale industries in the field of Maps and GIS. He is a Gold Medalist in M.Tech(Spatial Information Technology) and owns some famous Technology blogs and website... Know more

24 thoughts on “Formula to Find Bearing or Heading angle between two points: Latitude Longitude”

  1. I trying to understand the derivation of X and Y.

    I understand how the bearing is given in Radians as β = atan2(X,Y)
    My understanding is that here X is the long difference and Y is the lat difference.

    What I don’t understand is why long diff isn’t just PointBLong – PointALong
    in other words,
    X = -90.200203 – ( -94.581213) = 4.38101
    Y = 38.627089 – 39.099912 = -0.472823

    then β = atan2( 4.38101, -0.472823)

    What am I missing?

    1. Long diff varies with how far from equator toward the pole you are, in other words varies with latitude. I think the X and Y are actually reversed in the above derivation. It works for me but only when I reverse them within the argument of the ATAN2 function. Maybe Akshay could comment on this, please. Also, in the Haversine distance formula referenced (linked) above, the delta lat and delta long formulas use point #1 minus point #2 instead of traditional delta values where the first value is subtracted from the second (i.e. point #2 minus point #1). The simple way to see these derivations is to understand that the polar coordinates of lat/long are first converted to cartesian (X, Y, Z) where the polar direction of lat/long is parallel to the cartesian Z direction, +X points to 0,0 lat/long and +Y points to 0, +90 lat/long. The cartesian are then the typical or common Earth-centered coords. A diagram of this will show why a Latitude-dependent coefficient or multiplier term must accompany Longitude, since the distance subtended at Earth’s surface by some fixed angle of longitude changes with the latitude where that distance is measured. At North or South poles, that distance will become zero as all longitudes collapse to the same point, the pole. Along the Equator, that distance will be its maximum as the lat-dependent coefficient equals unity.

  2. Here’s another method;

    Distance & Azimuth from Position to Destination

    Distance = 90 – Sin-1(sin(Destination Latitude) x sin(Your present Latitude) + cos(Destination Latitude) x cos(Your present Latitude) x cos(Difference in Longitude between Your Location and Destination Location)

    Multiply answer by 60 to get Nautical miles.

    Another way

    Distance = 60 x Cos-1(sin(Destination Latitude) x sin(Your present Latitude) + cos(Destination Latitude) x cos(Your present Latitude) x cos(Difference in Longitude between Your Location and Destination Location)

    Azimuth to Destination

    NOTE- LHA= Present Longitude – Destination Longitude

    Z = tan-1(sin (LHA) / (cos (LHA) x sin(Your present Latitude) – cos(Your present Latitude) x tan(Destination Latitude))

    Then to put Z into the right quadrant, apply the following rules-

    If answer is negative, add 180º to Z
    LHA is NEGATIVE if it’s less than 180º .

    Another way

    tan-1(sin(LHA) / (cos(Present Latitude) x tan(Destination Latitude) – (sin(Present Latitude) x cos(LHA))
    -continued on next page-
    If LHA is greater than 180 it’s treated as a negative quantity.
    If the Azimuth angle as calculated is negative, add 180 to it.

  3. The values that I got according to formulation for x and y are different!!
    X = cos(38.627089) * sin(4.38101) = -0.566840755 but not 0.05967668696
    Y = cos(39.099912) * sin(38.627089) – sin(39.099912) * cos(38.627089) * cos(4.38101) = 0.32763159818398435 not -0.00681261948

    1. I had the same problem but I could figure out what was wrong. You have to convert your Lats and Longs to Radiant to get the correct results.
      Hopefully this helps.
      Greetings

  4. Hi..
    thanks for the formula, but I have a question,
    the resulting bearing angle, we should use it from the geographical North right?
    not the magnetic north?

    thanks in advance

    1. This formula is the conversion from a pair of
      [φ1, λ1, r ] , [φ2, λ2, r] spherical coordinates [latitude, longitude, earth radius] to
      d, θ where d is the angle at the centre of the earth between the points multiplied by the earth radius and θ is the angle of the arc on the surface compared to True North.
      The calculation of magnetic variation [magnetic north difference from True north] is different at every location on earth, but can be calculated here.
      https://www.ngdc.noaa.gov/geomag/calculators/magcalc.shtml#declination
      Try this for Kansas City
      https://www.ngdc.noaa.gov/geomag-web/calculators/calculateDeclination?lat1=39.099912&lon1=-94.581213&elevation=0&elevationUnits=F&model=WMM&startYear=2020&startMonth=2&startDay=28&resultFormat=html

  5. Would someone please explain why the following set of coordinates (a to b, and c to d) have relatively similar direction but the bearing angles are so different?
    a: (39.099912, -94.581213)
    b: (38.627089, -90.200203)
    bearing angle from a to b is 96.513

    c: (48.35, -122.65)
    d: (26.2697, 50.6260)
    bearing angle from c to d is 6.244

    Thanks

      1. Further,
        From 122°W to 50°E is almost diametrically opposite on the globe [172° difference]. So the resultant direction is ALMOST along a meridian of longitude [Obviously 6° different!!] and via the Polar Region. If destination had been 58°E it would be due north/south and over the geographic pole.

  6. Very nice! Your formulas are very easy to do. I suggest you to include other technical formulas like haversine formula. Bye

  7. what does the letter a preceding tan refer to ie, what’s the difference between tan and atan ? and between sin and asin ?

  8. ∆L is never explained. It’s actually = ( Latitude B – Latitude A)

    also you need to convert every number within cos and sin brackets to radians.
    so this is NOT true:

    X = cos(38.627089) * sin(4.38101)
    X = 0.05967668696

    but THIS is true
    X = cos(38.627089*π/180) * sin(4.38101*π/180)
    X = 0.05967668696

    same applies for the second formula for Y

  9. Dear Akshay,
    Thank you for very good examples. I have implemented your bearing between two points calculation and it works fine for your example of flying from Kansas City to St. Louis: β = 96.51°. However, your equations do not work if we will fly back – from St. Louis to Kansas City. I would expect that bearing will be
    180°+96.51° = 276.5126°. Your equation produces -80.7376°. Even if we will add this negative this value to 360° it will produce 279.2624°.
    Apparently something is missing. Please advise.

    Best wishes,
    Oleg

    1. Oleg,
      The great circle route is not a line of constant heading (except along the equator or due North/South). The heading on the route from Kansas City to St Louis STARTS as 096.51° at Kansas City, but it will be 99.26° as you arrive at St Louis. The reverse direction will be 279.26° at St Louis and 276.51 as you arrive at Kansas City. This is because on a sphere the “straight line” is a curve on the earth’s surface [a curve at constant radius from the earth’s centre].
      A great circle is the shortest track on the earth’s surface between the two points on the surface which also cuts through the earth’s centre [this would leave two perfectly equal hemispheres and not a smaller and bigger part]. Unfortunately, the direction shown in the calculation is relative to “North” and North is a different direction in 3D from any start point and converges on the geographic pole [travel North from any location on earth and you will eventually arrive at the North Pole. Although two people with different starting points would meet at the pole they would be coming from different directions!].
      On a map [which is not a globe] the great circle between any two points in the same hemisphere which are not North/South curve towards the nearest Pole. Try this on Google Earth, using the ruler to draw a line and read the heading [it is easy to visualise on longer distances when the earth is obviously a spheroid, like from Sacramento [38.7N, 121.6W] to Washington DC [38.85N, 77.04W]]. Turn on the Latitude/Longitude grid [CTRL-L] and you can see the track will cross 40°N twice and nearly reach 41°N in Central Nebraska .
      FYI, Sacramento to Washington starts at 075° [ENE] and arrives at Washington at 104° [ESE].

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.