Monday, December 10, 2012

Calculating Heading Or Bearing Angle Of GPS Coordinates


Heading is the direction you are walking or driving a vehicle or flying, it is using units of degrees with the north as a point of 0 or 360 degrees. East is 90 degrees, south is 180 degrees, and west as 270 degrees. North may use the magnetic north (compass), but can also use an absolute north (North Pole).


In this attached excel sheet, I use the absolute north as a point of north or 0 degree.





Suppose you are walking from point A to point C, or from starting point to a camp as the above picture, through point B or a bridge at north. Start at point A, you move to the north to point B, or the so-called heading 0 degree, as far as 10 km. Arriving at point B, you turn to the right, or the so-called 90-degrees heading and walk towards point C with 10 km distance. Bearing is the angle of the starting point towards the end of the journey or the destination point, or position of an object from the observer. So a bearing, can be composed of several headings. In the example above, bearing from point A to point C is 45 degrees. Bearing is also called azimuth.

GPS coordinate system used on the Excel sheet is a decimal number, because it is more easily calculated. On ‘conversion’ sheet, there are formulas to change decimal number to sexagesimal (degrees minutes seconds).

Please note the sequence of latitude and longitude coordinate, not to reverse. Google Maps uses a system of latitude and longitude (y and x), instead of as usual in mathematics longitude and latitude (x and y).

Heading when start is not always the same as when finish, especially for long distance. If we are near the equator, heading at the beginning and at the end of travel can be almost the same. It is because of our position on the north and south poles are always about the same. For example a flight conducted along the equator toward the east (heading 90 degrees). As long as the aircraft follows the equator and towards the east, in any position, the north pole is always on the left, and the south pole is always on the right of that aircraft.

Likewise, if we fly along the line of latitude. For example from the south pole to the north pole. During the trip, either at the start or near the destination, north pole position is always in front and the south pole is always in the back. So heading at the start and at the end of flight is almost the same 0 degree.

But if the journey is done over the pole, for example: the north pole, at the beginning of the trip heading 0 or 360 degrees. When passing over the north pole (90,0), the heading will change to 180 degrees.

For example: flights from Pulkovo International Airport, Saint Petersburg, Russia (59.800278, 30.262500) to the Ted Stevens Anchorage International Airport, Alaska, United States of America (61.17417, -149.99833). At Saint Petersburg, Russia after take off; initial heading 0.147 or to the north, when approaching Anchorage just before landing, heading is changed to 179.844 or heading to the south. Even though the flight is following straight line. And the shortest distance between Saint Petersbug to Anchorage is over the north pole.

So to explain the flight path, mid point needs to be calculated, ie the point in the middle of a trip. Saint Petersburg flight towards Anchorage has mid point at (89.309101, 36.265637). Heading at the mid point is 6,130 degrees.

Another example: a flight from Bordeaux Airport, Merignac, France (44.830309, -0.701237) to Toronto Pearson International Airport, Mississauga, Ontario, Canada (43.67768, -79.624958). After takeoff in Bordeaux, flight will be heading to 298.900 degrees. Half way will be at mid point (51.605128, -40.625340) and heading will become 268.540 degrees. Before landing in Toronto, the final heading is 239.258 degrees. So after take off flight heads to approximately north-west, at the mid point heads to the west, while approaching Toronto flight heads to approximately the southwest.

Both cities Bordeaux and Toronto are at nearly the same latitude line, which is about 44 degrees north latitude. But because the shape of the globe, the shortest distance between the two cities does not follow that latitude line. The shortest distance between Bordeaux and Toronto is over the mid point located at 51.6 degrees north latitude, about 8 degrees more to the north of the latitude of Bordeaux and Toronto. If flying from Bordeaux to Toronto follows the line of 44 degrees north latitude, it will always be a constant heading of about 270 degrees. The north pole will always be on the right, and the south pole is always on the left.

The picture below is a globe that is stretched into two dimensions or flat, showing that the latitude (blue) is always parallel to the equator (red, latitude 0). The compass direction of the absolute north-south pole (not the earth's magnetic pole) always follows longitude (black).


An airplane from Seoul Incheon International Airport (South Korea, Republic of Korea) (37.460395, 126.440717). The aircraft was headed for Amsterdam Airport Schiphol (Netherlands) (52.310545, 4.768124). Seen in the Google maps image below.



Although the two airports have almost the same latitude coordinates of around 37-52 degrees, the flight does not follow a parallel line with the equator, namely: passing over China, Kyrgyzstan, Kazakstan, etc.. Because the earth is like a ball, not flat, the closest distance is over China, Mongolia, Rusia, etc..

Then it will be read on the compass on the aircraft: the initial heading from Seoul flight to Amsterdam is 327.710 degrees, the heading at the mid point changes to 227.186 degrees, and at the final point near Amsterdam is 289.147 degrees. Although the aircraft is actually flying straight in the shortest path, following the curvature of the earth.

Earth radius used is 6,378.14 km and it is radius of the earth at the equator. Earth radius number can be adjusted for better accuracy because the earth is not perfectly round. The average value of earth radius is 6371 km. While the Earth's polar radius is 6,356.7523 km.

Read also calculating land lot area by GPS coordinates.

If using Google Maps, then the calculation result can be copied and paste in the Search box on Google Maps, then press the Search button. Google Maps will show the intended point on the map.

For Muslims, this heading formula can be used to calculate and find the qibla direction. By entering the coordinates of your position as the starting point, and the coordinates of the Kaaba (al-Ka╩┐bah al-Musharrafah, Mecca, Saudi Arabia) as the end point. For example: the qibla direction from Delhi (India) is:

Start: latitude 28.6100, longitude 77.230000 Delhi
End : latitude 21.4225, longitude 39.826167 Kaaba

The formula on the Excel sheet will produce an initial heading  266.614 degrees, or about west direction. This angle is used as the qibla direction from a position in Delhi.


Another example:

Start: latitude 23.5000, longitude 54.500000 Dubai
End : latitude 21.4225, longitude 39.826167 Kaaba

The calculation of the Excel formula will produce an initial heading of 264,154 degrees, or around the west for the qibla direction at Dubai.