AI Assistant
Notifications
Clear all

d.mmssss (DMS) to decimal degrees

12 Posts
5 Users
0 Reactions
443 Views
lukenz
(@lukenz)
Posts: 560
Member
Topic starter
Translate
English
Spanish
French
German
Italian
Portuguese
Russian
Chinese
Japanese
Korean
Arabic
Hindi
Dutch
Polish
Turkish
Vietnamese
Thai
Swedish
Danish
Finnish
Norwegian
Czech
Hungarian
Romanian
Greek
Hebrew
Indonesian
Malay
Ukrainian
Bulgarian
Croatian
Slovak
Slovenian
Serbian
Lithuanian
Latvian
Estonian
 

May not be a common problem but if you have 90.11020374 as DMS (i.e. 90?ø11'02.0374") in cell L2 in excel then =INT(L2)+TRUNC(MOD(L2,1)*100)/60+(MOD(L2,1)*100-TRUNC(MOD(L2,1)*100))*100/3600 seems to convert it to decimal degrees.

The controller software outputs it in the initial format and trying to do some calculations in excel hence the need to get it in decimal degrees so it can be converted to radians to use the trig functions in excel.


 
Posted : July 27, 2019 4:21 am
mathteacher
(@mathteacher)
Posts: 2243
Member
Translate
English
Spanish
French
German
Italian
Portuguese
Russian
Chinese
Japanese
Korean
Arabic
Hindi
Dutch
Polish
Turkish
Vietnamese
Thai
Swedish
Danish
Finnish
Norwegian
Czech
Hungarian
Romanian
Greek
Hebrew
Indonesian
Malay
Ukrainian
Bulgarian
Croatian
Slovak
Slovenian
Serbian
Lithuanian
Latvian
Estonian
 

Try it with a negative angle.


 
Posted : July 27, 2019 4:31 am
lukenz
(@lukenz)
Posts: 560
Member
Topic starter
Translate
English
Spanish
French
German
Italian
Portuguese
Russian
Chinese
Japanese
Korean
Arabic
Hindi
Dutch
Polish
Turkish
Vietnamese
Thai
Swedish
Danish
Finnish
Norwegian
Czech
Hungarian
Romanian
Greek
Hebrew
Indonesian
Malay
Ukrainian
Bulgarian
Croatian
Slovak
Slovenian
Serbian
Lithuanian
Latvian
Estonian
 

I should preface the above with we only work in azimuth angles and vertical angles in our neck of the woods so I wouldn't have much need for that.

Plugging in a negative value does send things out to sea which I think is what you are inferring?

Do you have a better formula?


 
Posted : July 27, 2019 4:51 am
just-a-surveyor
(@just-a-surveyor)
Posts: 1945
Member
Translate
English
Spanish
French
German
Italian
Portuguese
Russian
Chinese
Japanese
Korean
Arabic
Hindi
Dutch
Polish
Turkish
Vietnamese
Thai
Swedish
Danish
Finnish
Norwegian
Czech
Hungarian
Romanian
Greek
Hebrew
Indonesian
Malay
Ukrainian
Bulgarian
Croatian
Slovak
Slovenian
Serbian
Lithuanian
Latvian
Estonian
 
Posted by: @lukenz

I should preface the above with we only work in azimuth angles and vertical angles in our neck of the woods

Just a point that needs clarifying, Are you using vertical angles or zenith angles??ÿ


 
Posted : July 27, 2019 6:09 am
mathteacher
(@mathteacher)
Posts: 2243
Member
Translate
English
Spanish
French
German
Italian
Portuguese
Russian
Chinese
Japanese
Korean
Arabic
Hindi
Dutch
Polish
Turkish
Vietnamese
Thai
Swedish
Danish
Finnish
Norwegian
Czech
Hungarian
Romanian
Greek
Hebrew
Indonesian
Malay
Ukrainian
Bulgarian
Croatian
Slovak
Slovenian
Serbian
Lithuanian
Latvian
Estonian
 

@lukenz

I think that changing the first integer function to truncate will fix it. You never know when somebody might use that formula in another application that does encounter negative angles.


 
Posted : July 27, 2019 6:23 am

ladd-nelson
(@ladd-nelson)
Posts: 738
Member
Translate
English
Spanish
French
German
Italian
Portuguese
Russian
Chinese
Japanese
Korean
Arabic
Hindi
Dutch
Polish
Turkish
Vietnamese
Thai
Swedish
Danish
Finnish
Norwegian
Czech
Hungarian
Romanian
Greek
Hebrew
Indonesian
Malay
Ukrainian
Bulgarian
Croatian
Slovak
Slovenian
Serbian
Lithuanian
Latvian
Estonian
 

@lukenz

The following formula would be so much shorter with some intermediate cells serving as surrogates but I believe this formula would handle negative values and second values of varying lengths (I did not test in situations where only dd.mm are provided. Again, source dd.mmsssss value in cell L2 is assumed):

=TRUNC(L2) & RIGHT(MID(L2,SEARCH(".",L2)+1,2)/60+(RIGHT(L2,LEN(L2)-SEARCH(".",L2)-2)/10^(LEN(RIGHT(L2,LEN(L2)-SEARCH(".",L2)-2))-2))/3600,LEN(MID(L2,SEARCH(".",L2)+1,2)/60+(RIGHT(L2,LEN(L2)-SEARCH(".",L2)-2)/10^(LEN(RIGHT(L2,LEN(L2)-SEARCH(".",L2)-2))-2))/3600)-1)

I hope this information helps.


 
Posted : July 27, 2019 4:11 pm
lukenz
(@lukenz)
Posts: 560
Member
Topic starter
Translate
English
Spanish
French
German
Italian
Portuguese
Russian
Chinese
Japanese
Korean
Arabic
Hindi
Dutch
Polish
Turkish
Vietnamese
Thai
Swedish
Danish
Finnish
Norwegian
Czech
Hungarian
Romanian
Greek
Hebrew
Indonesian
Malay
Ukrainian
Bulgarian
Croatian
Slovak
Slovenian
Serbian
Lithuanian
Latvian
Estonian
 

@mathteacher

yes fair point, not a big deal for me but would be important for those trying to use it with lat/longs or quadrant bearings


 
Posted : July 28, 2019 2:13 am
lukenz
(@lukenz)
Posts: 560
Member
Topic starter
Translate
English
Spanish
French
German
Italian
Portuguese
Russian
Chinese
Japanese
Korean
Arabic
Hindi
Dutch
Polish
Turkish
Vietnamese
Thai
Swedish
Danish
Finnish
Norwegian
Czech
Hungarian
Romanian
Greek
Hebrew
Indonesian
Malay
Ukrainian
Bulgarian
Croatian
Slovak
Slovenian
Serbian
Lithuanian
Latvian
Estonian
 

@ladd-nelson

another good option, was trying to avoid using the text functions in excel.  If I came up with more significant figures for the seconds I could just adjust the final *100/3600 to suit *1000/36000 etc.


 
Posted : July 28, 2019 2:17 am
lukenz
(@lukenz)
Posts: 560
Member
Topic starter
Translate
English
Spanish
French
German
Italian
Portuguese
Russian
Chinese
Japanese
Korean
Arabic
Hindi
Dutch
Polish
Turkish
Vietnamese
Thai
Swedish
Danish
Finnish
Norwegian
Czech
Hungarian
Romanian
Greek
Hebrew
Indonesian
Malay
Ukrainian
Bulgarian
Croatian
Slovak
Slovenian
Serbian
Lithuanian
Latvian
Estonian
 

@just-a-surveyor

zenith angles are what the TS is storing, then I use =ABS(90-L2) to convert to vertical angles so I can do the slope distance reduction to horizontal distance/vertical distance


 
Posted : July 28, 2019 2:21 am
ladd-nelson
(@ladd-nelson)
Posts: 738
Member
Translate
English
Spanish
French
German
Italian
Portuguese
Russian
Chinese
Japanese
Korean
Arabic
Hindi
Dutch
Polish
Turkish
Vietnamese
Thai
Swedish
Danish
Finnish
Norwegian
Czech
Hungarian
Romanian
Greek
Hebrew
Indonesian
Malay
Ukrainian
Bulgarian
Croatian
Slovak
Slovenian
Serbian
Lithuanian
Latvian
Estonian
 

@lukenz

OK, how about this modification then, which uses the length of L2 to govern the length of the result and converts the the text string result into its numerical value?

=VALUE(LEFT(TRUNC(L2) & RIGHT(MID(L2,SEARCH(".",L2)+1,2)/60+(RIGHT(L2,LEN(L2)-SEARCH(".",L2)-2)/10^(LEN(RIGHT(L2,LEN(L2)-SEARCH(".",L2)-2))-2))/3600,LEN(MID(L2,SEARCH(".",L2)+1,2)/60+(RIGHT(L2,LEN(L2)-SEARCH(".",L2)-2)/10^(LEN(RIGHT(L2,LEN(L2)-SEARCH(".",L2)-2))-2))/3600)-1),LEN(L2)))

Tweak to tastes... 🙂


 
Posted : July 28, 2019 8:49 am

john-hamilton
(@john-hamilton)
Posts: 3438
Member
Translate
English
Spanish
French
German
Italian
Portuguese
Russian
Chinese
Japanese
Korean
Arabic
Hindi
Dutch
Polish
Turkish
Vietnamese
Thai
Swedish
Danish
Finnish
Norwegian
Czech
Hungarian
Romanian
Greek
Hebrew
Indonesian
Malay
Ukrainian
Bulgarian
Croatian
Slovak
Slovenian
Serbian
Lithuanian
Latvian
Estonian
 

hence the reason I use grads (aka gons, where 2PI=400g, 0.9g=1?ø) rather than DMS in all my comps.


 
Posted : July 28, 2019 10:15 am
mathteacher
(@mathteacher)
Posts: 2243
Member
Translate
English
Spanish
French
German
Italian
Portuguese
Russian
Chinese
Japanese
Korean
Arabic
Hindi
Dutch
Polish
Turkish
Vietnamese
Thai
Swedish
Danish
Finnish
Norwegian
Czech
Hungarian
Romanian
Greek
Hebrew
Indonesian
Malay
Ukrainian
Bulgarian
Croatian
Slovak
Slovenian
Serbian
Lithuanian
Latvian
Estonian
 

That's a knotty little problem if you want to create a completely general formula. Modulus arithmetic won't handle negative angles and calculations in floating point arithmetic sometimes frustrate the truncate function by leaving numbers just tiny bit less than the whole number they represent.

The one below covers a lot of bases. It handles negative angles, zero or blank seconds, and any reasonable number of decimal places in seconds. But it relies on an ancient trick from olden programming days, namely adding a tiny amount to a floating point number to bump it over an integer hump, and a test for positive or negative input.

The math is straight forward, the bugs remain to be found. Give it a try.

=if(L2>0,trunc(L2)+trunc(100*(L2+1E-14-trunc(L2)))/60+100*(100*L2-trunc(100*L2))/3600,trunc(L2)+trunc(100*(L2-1E-14-trunc(L2)))/60+100*(100*L2-trunc(100*L2))/3600)


 
Posted : July 28, 2019 11:55 am