> Script Details
Add x and y to the attribute table of a point or polygon layer
report inappropriate content
Feb 18 2004
Status of work
ArcScripts is intended for the free exchange of scripts and tools related to ESRI software products. Please alert the moderator if this script is a demo, trial-version, or an advertisement for a retail product.
The program adds x and y coordinates (Centroid or label point) to the selected polygon or point feature layer in an ArcMap data frame. If the field XCOORD or YCOORD does not exist in the layer, the program will add the field to the layer attribute table. The values of the coordinates that are added to the attribute table are in same coordinate and projection as the one sets in the Data Frame Properties. In that case, user can control what coordinate and projection of the x and y should be in the attribute table.
To make the script work on your ArcMAP,
1. Open your ArcMAP document with the data layer loaded and selected;
2. Start VB Editor by clicking Tools|Macros|visual Basic Editor;
3. Load the script addxy2ptpy.txt to the editor by clicking File|Import File... in the VB Editor
4. Close the VB Editor and return to ArcMAP
5. Run the script by clicking Tools|Macros|Macros... then clicking RUN button while Addxy2Att is highlighted.