English

How To: Add the X and Y components of a polygon or coverage annotation centroid to fields in the attribute table

Summary

Use the field calculator to populate X and Y data fields with the X and Y components of a polygon or coverage annotation centroid.

Procedure

  1. Create an number field named X_Value.
    1. Open the table and select Start Editing from the Table menu.
    2. Select Add Field from the Edit menu.
    3. In the Field Definition dialog box:
      1. Set Name to an appropriate name, for example 'Area'.
      2. Set Type to Number.
      3. Set Width to an appropriate number, for example '32'.
      4. Set Decimal Places to the desired number, for example '6'.
      5. Click OK.
    4. Select Stop Editing from the Table menu and save the edits.
  2. Create an number field named Y_Value.
    1. Open the table and select Start Editing from the Table menu.
    2. Select Add Field from the Edit menu.
    3. In the Field Definition dialog box:
      1. Set Name to an appropriate name, for example 'Area'.
      2. Set Type to Number.
      3. Set Width to an appropriate number, for example '32'.
      4. Set Decimal Places to the desired number, for example '6'.
      5. Click OK.
    4. Select Stop Editing from the Table menu and save the edits.
  3. Select Start Edting from the Table menu if not already in edit mode.
  4. Make the X_Value field active.
  5. Select Field Calculator from the Table menu.
  6. Enter the following code in the expression box at the bottom of the Field Calculator.
    Code:
    [shape].returncenter.getx
  7. Click OK.
  8. Make the Y_Value field active.
  9. Select Field Calculator from the Table menu.
  10. Enter the following code in the expression box at the bottom of the Field Calculator.
    Code:
    [shape].returncenter.gety 
    Note:
    You can also use the addxycoo.ave sample script that comes with ArcView to return the polygon centroids.