# Looking for a 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.

Thank you.

-
WGS84 is already in lat/long. – underdark Jun 7 '11 at 12:26
you want to convert from DD to DMS. You could re-submit another question asking this. – artwork21 Jun 7 '11 at 12:37
Thank you, artwork21. Will do. – Shaun Rollins Jun 7 '11 at 12:38
will you be using a certain GIS solution? If so, by providing that info may give you better answers from the community. – artwork21 Jun 7 '11 at 12:59

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.

-
I invite the anonymous downvoter to improve this reply ;-). (I believe he has the rep to do it.) – whuber Jun 7 '11 at 19:19
+1 just for calling out whoever that was haha – Ragi Yaser Burhum Jun 7 '11 at 19:56

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

-

It may help you. Just try. http://transition.fcc.gov/mb/audio/bickel/DDDMMSS-decimal.html

-
+1 Nice find. I notice this applet requires longitudes in the range [-180, +180]. The source code appears near the bottom of the page's source. – whuber Jun 7 '11 at 19:31

There's a nice simple class to do this over at StackOverflow in C#: http://stackoverflow.com/questions/4504956/formatting-double-to-latitude-longitude-human-readable-format

-