# Thread: Convert degrees minutes seconds to decimal degrees

1. Junior Member
Join Date
Nov 2016
Posts
7

## Convert degrees minutes seconds to decimal degrees

Hello

What is the most efficient way to convert a value in degrees minutes & seconds to decimal degrees ?
For example:

135°49'54" --> 137.83166667

I can use a series of split strings & , split & replace to separate into separate degrees, minutes & seconds & from there, the maths is easy
But I suspect there is a better way
Note- the length of the degrees values varies, sometimes 2 digits, so I can't use Strings Cut

thanks

Andrew

2. Junior Member
Join Date
Nov 2016
Posts
7
To partially answer my question (I'm not sure if it efficient, but it works)

Step 1. Use java expressions to extract degrees, minutes & seconds values

degrees: bearing.substring(0,(bearing.indexOf("°")))
minutes: bearing.substring((bearing.indexOf("°"))+1,(bearing.indexOf("'")))
seconds: bearing.substring((bearing.indexOf("'"))+1,bearing.indexOf('"'))

Step 2- use java expression to calculate the decimal value
degrees + ((minutes/60) +(seconds/3600))

If anyone has a better way, I'd be interested to see it

Andrew

3. Senior Member
Join Date
Aug 2016
Posts
290
That looks good.

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•