SUMMARY
Angular measurements are commonly expressed in units of degrees, minutes, and seconds (DMS). One degree equals 60 minutes, and one minute equals 60 seconds. To simplify some mathematical calculations you may want to express angular measurements in degrees and decimal fractions of degrees.
This article contains a sample custom function you can use to convert a degree value stored in decimal format, to DMS stored in text format, and a sample function that converts DMS to a degree value stored in decimal format.
In engineering field especially in telecommunication industry, it's very usual to use. Because the different data get from difference format, it should be to convert to the suitable format which support to your tools or format used.
Converting Decimal Degrees to Degrees/Minutes/Seconds
The following Microsoft Visual Basic for Applications custom function accepts an angle formatted as a decimal value and converts it to a text value displayed in degrees, minutes, and 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
=Convert_Degree(A1)
Converting Degrees/Minutes/Seconds to Decimal Degrees
The following Microsoft Visual Basic for Applications custom function accepts a text string of degrees, minutes and seconds formatted in the exact same format that the Convert_Degree function returns (for example, 10° 27' 36") and converts it to an angle formatted as a decimal value. This is exactly the reverse of the Convert_Degree custom function.WARNING: This custom function fails if the Degree_Deg argument is not in the following format
<degrees>° <minutes>' <seconds>"
even if the seconds value is 0.
Function Convert_Decimal(Degree_Deg As String) As Double
' Declare the variables to be double precision floating-point.
Dim degrees As Double
Dim minutes As Double
Dim seconds As Double
' Set degree to value before "°" of Argument Passed.
degrees = Val(Left(Degree_Deg, InStr(1, Degree_Deg, "°") - 1))
' Set minutes to the value between the "°" and the "'"
' of the text string for the variable Degree_Deg divided by
' 60. The Val function converts the text string to a number.
minutes = Val(Mid(Degree_Deg, InStr(1, Degree_Deg, "°") + 2, _
InStr(1, Degree_Deg, "'") - InStr(1, Degree_Deg, _
"°") - 2)) / 60
' Set seconds to the number to the right of "'" that is
' converted to a value and then divided by 3600.
seconds = Val(Mid(Degree_Deg, InStr(1, Degree_Deg, "'") + _
2, Len(Degree_Deg) - InStr(1, Degree_Deg, "'") - 2)) _
/ 3600
Convert_Decimal = degrees + minutes + seconds
End Function
- Start Excel and press ALT+F11 to start the Visual Basic Editor.
- On the Insert menu, click Module.
- Enter the sample code for the Convert_Decimal custom function described above into the module sheet.
- Press ALT+F11 to return to excel.
- In cell A1 type the following formula:=Convert_Decimal("10° 27' 36""")NOTE: You are required to type three quotation marks (""") at the end of the argument of this formula to balance the quotation mark for the seconds and the quotation mark for the text string. A cell reference will not require a quotation mark.
- The formula returns 10.46
Sample view:
Crosschek DMS and Decimal location on google earth:
Longitude (DMS)
|
Latitude (DMS)
|
Script Long (decimal)
|
Script Lat (decimal)
|
Long (decimal)
|
Lat (decimal)
|
106° 46' 4.85"
|
6° 11' 17.54"
|
=convert_decimal(B27)
|
=convert_decimal(C27)
|
106.7680139
|
6.188205556
|
106° 37' 56.00"
|
6° 13' 19.16"
|
=convert_decimal(B28)
|
=convert_decimal(C28)
|
106.6322222
|
6.221988889
|
Crosschek DMS and Decimal location on google earth:
Original Source : https://support.microsoft.com/en-us/kb/213449
Belum ada tanggapan untuk "How to convert Degree/Minutes/Second (DMS) angles to or from Decimals angles on Microsoft Excell"
Post a Comment