# Obtain direction from course heading

#### Steve

##### Member
Longtime User
The following function returns a string direction such as "north," "east southeast," etc from a heading between 0 and 360 degrees. You can use this with the GPS library to determine your direction.

Sub getDirection(COG)
Dim direction
if COG >= 0 And COG <= 11.25 Then direction = "north"
if COG > 348.75 and COG <= 360 Then direction = "north"
if COG > 11.25 and COG <= 33.75 Then direction = "north northeast"
if COG > 33.75 And COG <= 56.25 Then direction = "northeast"
if COG > 56.25 And COG <= 78.75 Then direction = "east northeast"
if COG > 78.75 And COG <= 101.25 Then direction = "east"
if COG > 101.25 And COG <= 123.75 Then direction = "east southeast"
if COG > 123.75 And COG <= 146.25 Then direction = "southeast"
if COG > 146.25 And COG <= 168.75 Then direction = "south southeast"
if COG > 168.75 And COG <= 191.25 Then direction = "south"
if COG > 191.25 And COG <= 213.75 Then direction = "south southwest"
if COG > 213.75 And COG <= 236.25 Then direction = "southwest"
if COG > 236.25 And COG <= 258.75 Then direction = "west southwest"
if COG > 258.75 And COG <= 281.25 Then direction = "west"
if COG > 281.25 And COG <= 303.75 Then direction = "west northwest"
if COG > 303.75 And COG <= 326.25 Then direction = "northwest"
if COG > 326.25 And COG <= 348.75 Then direction = "north northwest"
return direction
End Sub

Longtime User
Best regards.

#### NJDude

##### Expert
Longtime User
Look at the GPS documentation, especially BEARING