Notifications
Clear all

CONVERTING DECIMAL DEGREES TO DMS IN EXCEL TO TWO PLACES (EXAMPLE 10?ø47'25.32")

13 Posts
5 Users
0 Reactions
481 Views
ekillo
(@ekillo)
Posts: 559
Member
Topic starter
 

I need a little help with this.?ÿ What do I need to change to get two places on the seconds?

?ÿ

Function Convert_Degree(Decimal_Deg) As Variant
With Application
'Set degree to Integer of Argument Passed
Degrees = Int(Decimal_Deg)
'Set minutes to 60 times the number to the right
'of the decimal for the variable Decimal_Deg
Minutes = (Decimal_Deg - Degrees) * 60
'Set seconds to 60 times the number to the right of the
'decimal for the variable Minute
Seconds = Format(((Minutes - Int(Minutes)) * 60), "0")
'Returns the Result of degree conversion
'(for example, 10.46 = 10~ 27 ' 36")
Convert_Degree = " " & Degrees & "?ø " & Int(Minutes) & "' " _
& Seconds + Chr(34)
End With
End Function

?ÿ

Thanks,

Ed

 
Posted : July 3, 2019 5:25 pm
field-dog
(@field-dog)
Posts: 1433
Member
 

Looks like you got the code from https://support.microsoft.com/en-us/help/213449/how-to-convert-degrees-minutes-seconds-angles-to-or-from-decimal-angle .

I'll try to figure this out for you just because it's a challenge.

 
Posted : July 3, 2019 5:54 pm
field-dog
(@field-dog)
Posts: 1433
Member
field-dog
(@field-dog)
Posts: 1433
Member
 

https://www.excelsupersite.com/easily-convert-decimal-degrees-to-degrees-minutes-seconds-in-excel/

This looks like it addresses your issue.

 
Posted : July 3, 2019 6:18 pm
ekillo
(@ekillo)
Posts: 559
Member
Topic starter
 

Thanks.

I have never understood why this is not a built in function in EXCEL.

Ed

 
Posted : July 3, 2019 8:14 pm

jimcox
(@jimcox)
Posts: 2020
Member
 

Because excel, like most computers, thinks in Radians...

BTW I have a little add on for excel, that gives you the hms, r->p, etc functionality of the old HP calculators. Free for the asking...

?ÿ

 
Posted : July 4, 2019 1:00 am
ekillo
(@ekillo)
Posts: 559
Member
Topic starter
 

Jim,

I would like to get a copy of your program, I am working on a project for the next few months that I will be having to convert several hundred points.

Thanks,

Ed

 
Posted : July 4, 2019 1:27 am
mathteacher
(@mathteacher)
Posts: 2171
Member
 

You probably won't encounter any negative angles, but, if you do, the INT function will lead you astray. While INT(10.6) = 10, INT(-10.6) = -11. That's because the integer function selects the?ÿnext lowest integer, and -11 is lower than -10.?ÿ?ÿ

Using the truncate function solves that problem.

 
Posted : July 4, 2019 10:01 am
field-dog
(@field-dog)
Posts: 1433
Member
 

I'd like it, please.

 
Posted : July 4, 2019 10:15 am
loyal
(@loyal)
Posts: 3734
Member
 
Posted by: MathTeacher

You probably won't encounter any negative angles, but, if you do, the INT function will lead you astray. While INT(10.6) = 10, INT(-10.6) = -11. That's because the integer function selects the?ÿnext lowest integer, and -11 is lower than -10.?ÿ?ÿ

Using the truncate function solves that problem.

I know NOTHING about EXCELL (or any other such program, I never had any use for them), but wouldn't a negative Longitude (North America for example) be an issue as well?

Loyal

 
Posted : July 4, 2019 10:27 am

field-dog
(@field-dog)
Posts: 1433
Member
 

What is the source of your several hundred points in decimal degrees? Maybe Excel isn't the best solution for you.

 
Posted : July 4, 2019 10:29 am
mathteacher
(@mathteacher)
Posts: 2171
Member
 

Yes, as would negative convergence angles, which is where I was reunited with the problem. Back in my old Fortran days, we had a rounding subroutine from IBM called ROCSP. Lo and behold, it couldn't consistently round negative numbers correctly, so we wrote our own.

We also have to be careful about adding and subtracting decimal parts in these conversions as well.

 
Posted : July 4, 2019 11:37 am
ekillo
(@ekillo)
Posts: 559
Member
Topic starter
 

You are probably right, but I was sent an Excell file with a list of points in decimal degrees that I needed to locate, I know I could have gotten by not converting them, but I am old school and think in DMS.

 
Posted : July 4, 2019 8:41 pm