How To: Calculate Latitude and Longitude values using the Field Calculator.


Instructions provided describe how to use the Field Calculator to calculate latitude and longitude values for point features.


Using VBA Script Code in the Field Calculator, a field of type double can be populated with latitude or longitude values.

  1. Add a field of type double to the attribute table to store either latitude or longitude values.
  2. Start an edit session.
  3. Open the attribute table.
  4. Right-click the field and select Calculate Values.
  5. Check the 'Advanced' check box.
  6. Paste the following code into the 'Pre-Logic VBA Code' box:

    Dim Output As Double
    Dim pPoint As IPoint
    Set pPoint = [Shape]
    Output = pPoint.X

    The above code is for calculating Longitude. X should be changed to Y to calculate Latitude values.

  7. Type 'Output' into the lower text box.
  8. Click OK.

Related Information