Add XY Coordinates (Data Management)
Adds the fields POINT_X and POINT_Y to the point input features and calculates their values. It also appends the POINT_Z and POINT_M fields if the input features are Z- and M-enabled.
Add XY Coordinates is most commonly used to get access to point features to perform analysis or to extract points based on their x,y location.
If the POINT_X, POINT_Y, POINT_Z, and POINT_M fields exist, their values are recalculated.
If points are moved after using Add XY Coordinates, their POINT_X and POINT_Y values, and POINT_Z, and POINT_M values—if present—must be recomputed by running Add XY Coordinates again.
Project does not modify the values of POINT_X, POINT_Y, POINT_Z, or POINT_M.
If the Input Features are in a geographic coordinate system, POINT_X and POINT_Y represent the longitude and latitude, respectively.
If an ArcMap layer is selected as input , the x,y coordinates are based on the input's coordinate system, not that of the data frame.
This tool modifies the input data. See Tools with no outputs for more information and strategies to avoid undesired data changes.
The point features whose x,y coordinates will be appended as POINT_X and POINT_Y fields.
The following Python Window script demonstrates how to use the AddXY function in immediate mode.
import arcpy from arcpy import env env.workspace = "C:/data" arcpy.Copy_management("climate.shp", "climateXYpts.shp") arcpy.AddXY_management("climateXYpts.shp")
The following Python script demonstrates how to use the AddXY function in a stand-alone script.
# Name: AddXY_Example2.py # Description: Adding XY points to the climate dataset # Author: ESRI # Import system modules import arcpy from arcpy import env # Set workspace env.workspace = "C:/data" # Set local variables in_data= "climate.shp" in_features = "climateXPpts2.shp" # Copying data to preserve original dataset # Execute Copy arcpy.Copy_management(in_data, in_features) # Execute AddXY arcpy.AddXY_management(in_features)