4

I am working on an Java android project and have the following issue. I Searched so much but still I have the problem of converting the Latitude/Longitude values that are in DMS format (Eg: 38°2'56''N, 122°9'28''W) for their corresponding Decimal Degrees format.

Example values that need to be converted for their corresponding decimal degrees format.

38°49'59''N, 26°56'59''E

38°2'56''N, 122°9'28''W

34°52'58''S, 56°10'58''W

Thank you

JibW
  • 4,538
  • 17
  • 66
  • 101

3 Answers3

9

All you're doing when you convert DMS to decimal degrees is dividing by 60. Divide S by 60, add it to M, divide that result by 60, then add it to D.

The second part deals with the direction that the coordinates point. Picture a pair of axes with compass directions in their correct locations (i.e., up is N, right is E, down is S, left is W). This means that any decimal degree value corresponding to a DMS value that pointed either S or W is going to be negative.

38°2'56''N, 122°9'28''W -> 38.048889, -122.157778

Glendon Trullinger
  • 4,052
  • 1
  • 28
  • 35
  • Thanks Glendon. It works....... Thanks Sherif and Jenifer for ur quick responses. Sherifs formula is correct. Problem was the letter. – JibW Aug 04 '11 at 17:53
3

D°M'S''

  1. Divide S by 60 and get X
  2. Find Y by adding X to M
  3. Divide Y by 60 to get F
  4. Answer = D + F

SUMMARY

TO CONVERT FROM DMS TO DEGREE

Degrees = D + ((S/60)+M)/60

Where D and M and S are the values that compose the DMS format : D°M'S''

Sherif elKhatib
  • 45,786
  • 16
  • 89
  • 106
  • Ya, I tried this way.. But when I do like that, for this pair of values it points to a complete different location. [38°2'56''N, 122°9'28''W] – JibW Aug 04 '11 at 16:42
  • I will check the formula wait – Sherif elKhatib Aug 04 '11 at 16:43
  • 1
    My formula is correct and `[38°2'56''N, 122°9'28''W]` gives 38.048889 Latitude and 122.157778 Longitude – Sherif elKhatib Aug 04 '11 at 16:45
  • Hi Sherif, When I go and paste both value pairs in Google map it shows 2 different places [38°2'56''N, 122°9'28''W] && [38.048889, 122.157778 ] – JibW Aug 04 '11 at 16:54
  • 1
    no way! there must be some parameter that specifies whether the input is dms or degrees or sth like that ! Missing this param is causing the difference in the localization – Sherif elKhatib Aug 04 '11 at 17:09
  • I saw that this format I sent is DMS+Compass Direction http://www.geomidpoint.com/latlon.html ...... May be that N,S,E,W Letter makes the difference. I am Bit confusing with this.. – JibW Aug 04 '11 at 17:23
  • 2
    try these: `[-38.048889, 122.157778]`,`[38.048889, -122.157778]` and `[-38.048889, -122.157778]` : Any gives the right location? – Sherif elKhatib Aug 04 '11 at 17:46
  • Thanks Sherif.. This gives the right Answer [38.048889, -122.157778] – JibW Aug 05 '11 at 09:45
1

And you can always check your work with Sherif's formula here: http://transition.fcc.gov/mb/audio/bickel/DDDMMSS-decimal.html

Jennifer S
  • 1,419
  • 1
  • 24
  • 43
  • Ya, but when I go and paste these 2 value pairs in Google map it shows completely two different places. [38°2'56''N, 122°9'28''W] && [38.048889, 122.157778 ] – JibW Aug 04 '11 at 17:20