Knowledge Base - Technical Articles


Technical Article   HowTo:  Convert degrees minutes seconds values to decimal degree values using the Field Calculator

Article ID: 22455
Software:  ArcGIS - ArcEditor 9.2, 9.3, 9.3.1 ArcGIS - ArcInfo 9.2, 9.3, 9.3.1 ArcGIS - ArcView 9.2, 9.3, 9.3.1
Platforms:  Windows XP, Vista

Summary


 The procedure below is for ArcGIS 9.3.1 or earlier versions. Starting at ArcGIS 10.0, expressions in the Calculator are created using only VBScript or a standard Python format.

Instructions provided describe how to use the Field Calculator to convert Degrees Minutes Seconds stored in a string field to Decimal Degrees stored in a number field. The values must be stored in a field in a table as Degrees Minutes Seconds with no symbols. For example:

25 35 22.3

In the example, 25 is degrees, 35 is minutes and 22.3 is seconds.

Procedure

Follow the steps below.

 Initially perform the steps below on positive numbers. After the conversion is complete, multiple any fields that need to be negative by -1.


 The format of the records within the Degrees/Minutes/Second fields must be DD MM SS. Any blank records or records with extra spaces or characters, such as single or double quotes, may cause a user interrupted error.



  1. Add the table to ArcMap.
  2. Right-click on the table in the Table of Contents and click Open.
  3. Verify 'Edit' mode is not enabled. Click the Options button and select Add Field.
  4. Enter Lat2 in the Name field and select Double from the Type drop-down list. If Lat2 is already used as a field name, select a name that is not used.
  5. Verify that the Scale and Precision is set to 0 and click OK.
  6. Right-click on the Lat2 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 Pre-Logic VBA box:

    Dim Degrees as Double
    
    Dim Minutes as Double
    Dim Seconds as Double
    Dim DMS as Variant
    Dim DD as Double

    DMS = Split([Latitude])
    Degrees = CDbl(DMS(0))
    Minutes = CDbl(DMS(1))
    Seconds = CDbl(DMS(2))
    DD = (Seconds/3600) + (Minutes/60)+ Degrees

  10. Find the line that begins 'DMS. . .' The text within the brackets [ ] is the name of the field holding the latitude values. Replace the word Latitude in the code with the name of the field that stores the latitude values in the table.
  11. Paste the following code into the 'Lat2 =' box at the bottom of the dialog box.

    CDbl(DD)


    -show me-

    [O-Image]
  12. Click OK.
  13. Repeat steps 3 through 12 for the longitude values.

     Null values in the DMS field will cause an error when running the VBA code in the Field Calculator.


Created: 5/8/2002
Last Modified: 10/13/2011

Article Rating: (16)
If you would like to post a comment, please login

Comments

By arrteam - 04/20/2012 10:33 AM

Other - See details below.

I wanted specifics on how to create a shapefile or coverage? Do I need to develop a street network?

Rating:

By Anonymous - 01/11/2011 11:01 AM

The article contains a dead link.

I'm using 9.3.1 I received "Error running VBA code: Expected end of Statement" Trying to figure out what the error means.

Rating:

By Anonymous - 01/05/2011 1:40 PM

I have suggested related resources/links that can enhance this article. See below.

The article should have pointed out that the data must be in the format DD MM SS with no extra spaces or single or double quotes in the input fields. If there are extra characters, the program will end with a user interrupt error because it can assign some values to number fields.

Rating:

By Anonymous - 12/09/2010 8:32 AM

The article contains a dead link.

"Error running VBA code: Expected end of Statement"

By Anonymous - 11/30/2010 8:00 AM

The article contains a dead link.

followed the instructions to the letter, however got an "Error Running VBA code: User Interrupt" Using ESRI ArcMap 9.3.1 SP2 (build 4000) This is so frustrating!

Rating:

By Anonymous - 12/02/2009 10:02 AM

The article needs to be updated.

The article should mention that null values in the DMS field will cause an error when running the VBA code in the Field Calculator. Also, it would be useful if the more precise terminology would be used when referring to the "expression box". I believe the reference should be to the Pre-logic VBA box, at least for the most recent versions of ArcMap.

Rating:

By Anonymous - 04/06/2009 9:11 AM

The article is incorrect or the solution didn’t work.

Can't get the field calculation to work. I've followed the instructions exactly. Any help would be appreciated

Rating:

By Anonymous - 03/05/2009 1:36 AM

Great article! It helped a lot!

Just wanted to say thanks a million!!!! You saved me from converting 800 points manually!!!

Rating:

By Anonymous - 01/08/2009 2:57 AM

The article is incorrect or the solution didn’t work.

Dim Degrees as Double Dim Minutes as Double Dim Seconds as Double Dim DMS as Variant Dim DD as Double i try to use this script to convert from DMS to Decimal Degree, at my PC using ArcGIS 9.3 but it didn't work. i followed the step very carefully but failed. The message box appeared and said "Error Running VBA Code : User interrupt" DMS = Split ([LATITUDE]) Degrees = CDbl(DMS(0)) Minutes = CDbl(DMS(1)) Seconds = CDbl(DMS(2)) DD = (Seconds/3600) + (Minutes/60)+ Degrees

Rating:

By Anonymous - 08/29/2008 2:40 PM

The article needs to be updated.

I followed the steps to convert Lat / Long and it worked....except it put all my West Longitudes from NC in Asia! Guess these values needed to be mulitplied by -1? How do I multiply them now that the are in the field?

Rating:

By Anonymous - 12/03/2007 2:10 PM

The article needs to be updated.

I'm sure you know but it should be mentioned that it doesn't work with a negative sign in the field, it has to be added later.

Rating:

By Anonymous - 11/22/2005 10:37 AM

The Expression gives an incorrect answer if the Longitude is negative The following is a correction: Dim Degrees as Double Dim Minutes as Double Dim Seconds as Double Dim DMS as Variant Dim DD as Double DMS = Split([Longitude]) Degrees = CDbl(DMS(0)) Minutes = CDbl(DMS(1)) Seconds = CDbl(DMS(2)) If degrees > 0 Then DD = (Seconds/3600) + (Minutes/60)+ Degrees Else DD = -((Seconds/3600) + (Minutes/60)+ (-Degrees)) Endif

Rating:

By Anonymous - 02/17/2005 3:34 PM

Please modify this to account for negative degrees as follows: Dim Degrees as Double Dim Minutes as Double Dim Seconds as Double Dim DMS as Variant Dim DD as Double DMS = Split([Latitude]) Degrees = CDbl(DMS(0)) Minutes = CDbl(DMS(1)) Seconds = CDbl(DMS(2)) if degrees > 0 then DD = (Seconds/3600) +(Minutes/60)+ Degrees else DD = Degrees - (Minutes/60.00) - (Seconds/3600) endif

Rating:

By Anonymous - 01/21/2005 9:55 AM

This would be more useful if you changed the code to account for negative degrees (i.e. W or S) Dim Degrees as Double Dim Minutes as Double Dim Seconds as Double Dim DMS as Variant Dim DD as Double Dim strInput as String strInput = [LAT_DMS] DMS = Split(strInput) Degrees = CDbl(DMS(0)) Minutes = CDbl(DMS(1)) Seconds = CDbl(DMS(2)) If (Degrees < 0) then DD = -(Seconds/3600) - (Minutes/60) + Degrees Else DD = (Seconds/3600) + (Minutes/60)+ Degrees End If

Rating:

By Anonymous - 11/18/2004 2:47 PM

I finally got this to work. Thank you

Rating:

By Anonymous - 11/18/2004 2:35 PM

This does not work, apparantly the automated calculate does NOT support the convert to double fuction (CDbl).

By Anonymous - 02/25/2004 7:33 AM

Thank YOU !!! Very helpful, but i also need one inorder to convert Decimal minutes ---> Decimal Degrees

Rating:

By Anonymous - 01/29/2004 9:43 AM

I did find this useful especially for what I do, but the one thing that got me hung up on this was were to put the data. The steps did not tell me, they only let me assume and I thought the field I added would be were the new calculated numbers went. It would have been much easier if it were stated that the data needed to be in the table before you calculated it.

Rating:

By Anonymous - 10/14/2003 9:47 AM

The article should be more specific on the table type that can be used. I have added a table from a MS Access db but I cannot edit the table and "add field" is grayed out. Now what?