English

How To: Convert Decimal Degree values to Degree Minute Seconds values using the Field Calculator

Summary

Instructions provided describe how to use the Field Calculator to convert Decimal Degrees stored in a Numeric field to Degrees Minutes Seconds stored in a Text field. The output by default will be in the following format:

DDÂ�ºMM'SS.SS"N

Procedure

Follow the steps below:

  1. Add the table to ArcMap.
  2. Right-click on the Table in the Table of Contents and select Open.
  3. Verify 'Edit' mode is not enabled. Click the Options button and select Add Field.
  4. Enter DMSLat in the Name field and select Text from the Type drop-down list. If DMSLat is already used as a field name, select a name that is not being used.
  5. Change the length to 20.
  6. Right-click on the DMSLat field and select Calculate Values.
  7. Click Yes, if presented with a message box.
  8. Check the Advanced check box.
  9. Paste the following code into the expression box:

    Code:
    Dim DDField
    Dim zM1 As Double
    Dim Suffix As String
    Dim DMS As String
    Dim zY As Double
    Dim zD As Double, zM As Double, zS As Double
    Dim Dchr As String, Mchr As String, Schr As String
    Dim Degree As String, Minute As String, Second As String
    '=================================================
    'Adjust the variables below
    DDField = [DDLat] 'Change to field with decimal degree values
    Dchr = Chr(186) 'Character after degrees
    Mchr = Chr(39) 'Character after minutes
    Schr = Chr(34) 'Character after seconds
    '=====================================================
    zY = DDField
    If zY >= 0 Then
    Suffix = "N" 'N if Latitude, E if Longitude
    Else
    Suffix = "S" 'S if Latitude, W if Longitude
    End If
    zY = Abs(zY)
    zD = Int(zY)
    Degree = CStr(zD)
    zM = (zY - zD) * 60
    zM1 = Int(zM)
    Minute = CStr(zM1)
    zS = FormatNumber(((zM - zM1) * 60), 2)
    zS1 = Int(zS)
    Second = CStr(zS)
    DMS = Degree & Dchr & Minute & Mchr & Second & Schr & Suffix

  10. Change the value within the brackets next to 'DDField =' to the field in the table that contains the latitude decimal degree values. To change the characters after degrees minutes and seconds edit the value after 'Dchr =', 'Mchr =', and 'Schr =' respectively.
  11. Paste the following code into the 'DMSLat =' box at the bottom of the dialog box.

    Code:
    DMS

  12. Click OK to run the Field Calculator.
  13. Repeat steps 3 through 12 for the longitude values, but change the values within the code where Suffix = "N" to Suffix = "E" and where Suffix = "S" to Suffix = "W". Also, change the value next to 'DDField =' to the field in the table that contains the longitude decimal degree values.

Related Information