Skip to content

Instantly share code, notes, and snippets.

@RobertSudwarts
Created June 7, 2015 16:18
Show Gist options
  • Save RobertSudwarts/acf8df23a16afdb5837f to your computer and use it in GitHub Desktop.
Save RobertSudwarts/acf8df23a16afdb5837f to your computer and use it in GitHub Desktop.
[python] degrees to cardinal directions
def degrees_to_cardinal(d):
'''
note: this is highly approximate...
'''
dirs = ["N", "NNE", "NE", "ENE", "E", "ESE", "SE", "SSE",
"S", "SSW", "SW", "WSW", "W", "WNW", "NW", "NNW"]
ix = int((d + 11.25)/22.5)
return dirs[ix % 16]
@acidsafari
Copy link

This should probably be made a package

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment