Sunday, January 6, 2019

Convert "Decimal degrees (DD)" to "Degree Minutes and Seconds (DMS)" with Python

Often times, students may find themselves stuck on how to convert integers to degrees minutes and seconds (like i once was), surprising, it is one of the easiest task you'll learn on this post today.

Several methods can be used to accomplish this, the methods i'll discuss today include:


  1. Simple mathematical calculator method (Casio calculator)
  2. Manual method
  3. Python Algorithm script
Steps.


1. Using Python Algorithm

>>> def DDtoDMS(value):
        #print "THE VALUE TO CONVERTIS : ", value
        D = float(value)
        D = int(D)
        #print(D)
        m = float(float(value) - int(D))
        #print(m)
        M = int(float(m*60))
        #print(M)
        S = round(((m*60)-M)*60, 2)
        #print(S)
        #print( "%rd %rm %rs" %(D,M,S))
A GUI python program of the above code can be downloaded HERE!




2.Manual Method
  • For the degrees use the whole number part of the decimal
  • For the minutes multiply the remaining decimal by 60. Use the whole number part of the answer as minutes.
  • For the seconds multiply the new remaining decimal by 60

3. Using Casio calculator

  • On your casio (fx xxx) scientific calculator, simply put ON the calculator and enter the Decimal values.
  • Now press the black button on the third row and second column.
  • Note: If it does not give the DMS, press the shift button before the DMS button.


Thanks for reading!

1 comment: