We help IT Professionals succeed at work.

Check out our new AWS podcast with Certified Expert, Phil Phillips! Listen to "How to Execute a Seamless AWS Migration" on EE or on your favorite podcast platform. Listen Now


Convert a bearing in degrees to compass point

andieje asked
Medium Priority
Last Modified: 2012-05-07

I have a gps tracking system in a vehicle. It provides the position of the vehicle as a latitide and longitude coordinate using wgs84. Apparently the unit can provide a heading for the vehicle in degrees.

Firstly, how does it calculate the heading? I know you won't know for definite but you will probably have an intelligent idea. Perhaps it stores the previous gps position and then compares this to the current gps position and uses this to calculate a bearing?

Secondly, if I have a heading in degrees, how could i convert this into one of the 8 compass points from N, NE, E, SE, S, SW, W, NW

Many thanks
Watch Question

Jaime OlivaresSoftware Architect
Top Expert 2008

>>Apparently the unit can provide a heading for the vehicle in degrees.
Every GPS can provide you the rhumb (it is not always the same as the heading, specially for air/sea vehicles), but calculating by yourself is not a trivial stuff, because GPS use to give inaccurate positions that causes false heading calculations. For this, there is an algorithm named "Kalman Filter" that eliminates the error by providing many samples as input to have a stable heading value as output.
Besides this, calculating compass coordinates is quiet easy. Which programming language?



I dont know what a rhumb is. I looked it up on google but it doesnt seem to be possible to get a laymans explanation. However, I'm not sure I need to know exactly what it is but I would like to convert it to a compass bearing. I am using vb.net 2005.

Many thanks
Jaime OlivaresSoftware Architect
Top Expert 2008

don't worry about rhumb versus heading, it should be the same for terrestrial applications. About compass algorithm, here is some implementation of my own:

Public Function Quadrant(ByVal degrees As Single) As String
    Dim AllQuadrants As String = "NNE,NE,NEE,E,SEE,SE,SSE,S,SSO,SO,SOO,O,NOO,NO,NNO"
    Dim Quadrants As String() = AllQuadrants.Split(","c)
    If degrees > 348.75 OrElse degrees <= 11.25 Then
        Return "N"
    End If
    Dim q As Integer = CInt(Math.Floor((degrees - 11.25) / 22.5))
    Return Quadrantes(q)
End Function


Thats brilliant. However I only need the 8 compass points in my question. I don't know how to modify the code you have supplied to restrict it to just those compass points.

I could do something 'rough' like assigning the more detailed compass points to a more general one
e.g. if function returns NNE then convert it to NE but it would be nicer and easier to read if i could modif the function ou supplied
Software Architect
Top Expert 2008
Unlock this solution and get a sample of our free trial.
(No credit card required)


many thanks
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.