Created
April 2, 2013 00:27
-
-
Save chadcooper/5288967 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def dd_to_dms(dd): | |
"""Convert a coordinate in decimal degrees to a tuple of (deg, min, sec)""" | |
is_positive = dd >= 0 | |
dd = abs(dd) | |
minutes,seconds = divmod(dd*3600,60) | |
degrees,minutes = divmod(minutes,60) | |
degrees = degrees if is_positive else -degrees | |
return (degrees,minutes,seconds) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment