3

I have latitude/longitude represented as amount of seconds:

45'11"35 = 45*60*60 + 11*60 + 35 = 9720695

How can I convert back from something like 9720695 to DMS/Decimal?

2
  • I am not sure why you converted it that way. I go straight from dms to dd with d+m*60+s*3600 ... so the opposite of your seconds conversion. What use would you get from the seconds calculation?
    – Segrest
    Feb 12, 2017 at 19:18
  • Sometimes the data comes in this format
    – michael
    Feb 13, 2017 at 10:24

1 Answer 1

3

If you don't mind using Excel; you will get B1=45, C1=11, D1=35 with formula below.

A1: 162695
B1: =FLOOR(A1/3600, 1)             # D
C1: =FLOOR((A1/3600 - B1)*60, 1)   # M
D1: =A1-B1*3600-C1*60              # S
E1: =A1/3600                       # Decimal

Sorry I did not notice you were QGIS user. The above excel formula is basically applicable to Field calculator. One pitfall is floor() for negative number so x is put in abs(). If your data isn't in west (e.g. -45'11"35 for 45'11"35W) or south this may be overkill.

x: 162695
D: floor(abs("x")/3600) 
M: floor((abs("x")/3600 - floor(abs("x")/3600))*60)
S: abs("x")-floor(abs("x")/3600)*3600-(floor((abs("x")/3600-floor(abs("x")/3600))*60))*60

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.