Calculate the centroid of a polygon


Instructions provided describe how to use a VBA script in the Field Calculator to calculate latitude and longitude values for polygon centroids.


  1. Open the attribute table for the polygon feature class.
  2. In the attribute table, navigate to Options > Add Field and add two new Double fields. Name one Latitude and the other Longitude.
  3. Start an edit session.
  4. Right-click the Longitude Field > Field Calculator.
  5. Select Advanced.
  6. Paste the following script into the 'Pre-Logic VBA Code' Box:

    Dim Output As Double
    Dim pArea As IArea
    Set pArea = [Shape]
    Output = pArea.Centroid.X

  7. Type 'Output' with no quotes into the lower text box.
  8. Click OK.
  9. For the Latitude field, repeat steps 4 through 8 except change the X in the last line of the script to a Y.

Article ID:000009189

  • ArcMap 9 x

Get help from ArcGIS experts

Contact technical support

Download the Esri Support App

Go to download options

Discover more on this topic