How do you convert Decimal Degrees to Degrees Minutes Seconds In Python? Is there a Formula already written?
This is exactly what divmod
was invented for:
>>> def decdeg2dms(dd):
... mnt,sec = divmod(dd*3600,60)
... deg,mnt = divmod(mnt,60)
... return deg,mnt,sec
>>> dd = 45 + 30.0/60 + 1.0/3600
>>> print dd
45.5002777778
>>> decdeg2dms(dd)
(45.0, 30.0, 1.0)