Skip to content

Instantly share code, notes, and snippets.

@KMarkert
Last active November 10, 2018 20:15
Show Gist options
  • Save KMarkert/2fdbe1845ecc9897271c8c620faeb06d to your computer and use it in GitHub Desktop.
Save KMarkert/2fdbe1845ecc9897271c8c620faeb06d to your computer and use it in GitHub Desktop.
import math
def dd2dms(dd):
if dd < 0:
degrees = math.ceil(dd)
else:
degrees = math.floor(dd)
minutes = 60 * (dd%1)
seconds = 60 * (minutes%1)
return {'degrees':degrees,'minutes':math.floor(minutes),'seconds':seconds}
def dms2dd(degrees,minutes,seconds):
secDeci = '{}'.format((seconds/60)/100)
minDeci = '{}'.format(minutes/60)
dd = degrees + float(minDeci) + float(secDeci)
return {'decimal degrees': dd}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment