More

# Seeking tool to convert DD to DMS? I am looking for either an online tool or one that I can download to convert DD to DMS.

For example, I want to convert from:

41.590833, -93.620833 to 41° 35' 27" N, 93° 37' 15" W… Those are the coordinates, according to a Geohack, for Des Moines.

Because even the Microsoft code is buggy, it may be useful to provide correct pseudocode for the conversion.

To convert decimal degrees x to degrees (d), minutes(m), and (decimal) seconds (s), do the following:

``Declare d, m as integer, s as float If x < 0, then sign = -1 else sign = +1 Let y = Abs(x) ' Work with positive values only. Let d = Int(y) ' Whole degrees. Floor() is ok too. Let z = 60*(y - d) ' The fractional degrees, converted to minutes. Let m = Int(z) ' Whole minutes. Let s = 60*(z - m) ' The fractional minutes, converted to seconds. Assert sign*(((s/60) + m)/60 + d) == x ' This confirms a correct result. Return (sign*d, m, s)``

Instead of returning a signed degree, you can indicate N/S or E/W at the end:

``If x is a latitude, then If sign == -1 then hemisphere = "S" else hemisphere = "N" Else {x is a longitude} If sign == -1 then hemisphere = "W" else hemisphere = "E" End if Return (d, m, s, hemisphere)``

If you like, you can round s to an integer and format the results to match the form given in the question.

It's not very complicated to do, but I tend to just use this webpage. But let's work through the latitude in your example. The decimal degrees are the same, in this case 41. Now, take the remainder and multiply by 60. This gives you 35.44998. The integer part is the seconds (35'). Now, take the remainder and multiply by 60 again. You get the seconds (26.9998), which compares positively with your findings above.

Windows Calculator in Scientific mode does the trick for me.

The "dms" button takes you from decimal degrees to Degrees,Minutes,Seconds.

Inv+dms(now shown as deg) goes the other way.

Look this python library https://github.com/ewheeler/PyDecimalDegrees

or this online/offline scripts based on Perl http://www.movable-type.co.uk/scripts/latlong.html