Add Geometry Attributes (Data Management)
Summary
Adds new attribute fields to the input features representing the spatial or geometric characteristics and location of each feature, such as length or area and x, y, z, and mcoordinates.
Usage
This tool presents an easy and efficient way to automate the task that can also be accomplished using the Calculate Geometry dialog box or the Calculate Field geoprocessing tool.

One or many attribute fields will be added to the input features depending on the options specified in the Geometry Properties parameter. If the fields already exist in the input features, the values in those fields will be overwritten. Use the following table to determine what fields will be added for each geometry property:
Geometry property
Added field(s)
AREA
POLY_AREA: The area of the polygon.
AREA_GEODESIC
AREA_GEO: The geodesic area of the polygon.
CENTROID
CENTROID_X: The xcoordinate of the centroid point.
CENTROID_Y: The ycoordinate of the centroid point.
CENTROID_Z: The zcoordinate of the centroid point. This field is only added if the input features are zenabled.
CENTROID_M: The mcoordinate of the centroid point. This field is only added if the input features are menabled.
CENTROID_INSIDE
INSIDE_X: The xcoordinate of a central point inside or on the input feature.
INSIDE_Y: The ycoordinate of a central point inside or on the input feature.
INSIDE_Z: The zcoordinate of a central point inside or on the input feature. This field is only added if the input features are zenabled.
INSIDE_M: The mcoordinate of a central point inside or on the input feature. This field is only added if the input features are menabled.
EXTENT
EXT_MIN_X: The minimum xcoordinate of the feature.
EXT_MIN_Y: The minimum ycoordinate of the feature.
EXT_MAX_X: The maximum xcoordinate of the feature.
EXT_MAX_Y: The maximum ycoordinate of the feature.
LENGTH
LENGTH: The length of the line.
LENGTH_GEODESIC
LENGTH_GEO: The geodesic length of the line.
LENGTH_3D
LENGTH_3D: The 3D length of the line.
LINE_BEARING
BEARING: The starttoend bearing of the line. Values range from 0 to 360, with 0 meaning north, 90 east, 180 south, 270 west, and so on.
LINE_START_MID_END
START_X: The xcoordinate of the first point of the line or polygon border.
START_Y: The ycoordinate of the first point of the line or polygon border.
START_Z: The zcoordinate of the first point of the line or polygon border. This field is only added if the input features are zenabled.
START_M: The mcoordinate of the first point of the line or polygon border. This field is only added if the input features are menabled.
MID_X: The xcoordinate of the point halfway along the length of the line or polygon border.
MID_Y: The ycoordinate of the point halfway along the length of the line or polygon border.
MID_Z: The zcoordinate of the point halfway along the length of the line or polygon border. This field is only added if the input features are zenabled.
MID_M: The mcoordinate of the point halfway along the length of the line or polygon border. This field is only added if the input features are menabled.
END_X: The xcoordinate of the last point of the line or polygon border.
END_Y: The ycoordinate of the last point of the line or polygon border.
END_Z: The zcoordinate of the last point of the line or polygon border. This field is only added if the input features are zenabled.
END_M: The mcoordinate of the last point of the line or polygon border. This field is only added if the input features are menabled.
PART_COUNT
PART_COUNT: The number of parts comprising the feature.
PERIMETER_LENGTH
PERIMETER: The length of the polygon perimeter or border.
PERIMETER_LENGTH_GEODESIC
PERIM_GEO: The geodesic length of the polygon perimeter or border.
POINT_COUNT
PNT_COUNT: The number of points comprising the feature.
POINT_X_Y_Z_M
POINT_X: The xcoordinate of the point.
POINT_Y: The ycoordinate of the point.
POINT_Z: The zcoordinate of the point. This field is only added if the input features are zenabled.
POINT_M: The mcoordinate of the point. This field is only added if the input features are menabled.
If a coordinate system is specified, the length and area calculations will be in the units of that coordinate system unless different units are selected in the Length Unit and Area Unit parameters.
The attribute fields added by this tool are just like any fields that you can add to a feature layer. You can overwrite the field values, or delete or rename the fields. The values in these fields are not automatically recalculated after edits. If you edit the features, you'll need to run this tool again to update the field values.
If the input features have a selection, only the selected features will have values calculated in the added fields; all other features will have null values.
This tool works with point, multipoint, polyline, polygon, and annotation feature classes. Annotation is treated as a polygon feature class.
This tool modifies the input data. See Tools with no outputs for more information and strategies to avoid undesired data changes.
Syntax
Parameter  Explanation  Data Type 
Input_Features 
New attribute fields will be added to the input features to store properties such as length, area, or x, y, z, and mcoordinates.  Feature Layer 
Geometry_Properties [Geometry_Properties,...] 
Determines the geometry or shape properties that will be calculated into new attribute fields.
 String 
Length_Unit (Optional) 
The unit in which to calculate length.
 String 
Area_Unit (Optional) 
The unit in which to calculate area.
 String 
Coordinate_System (Optional) 
The coordinate system in which the coordinates, length, and area will be calculated. The coordinate system of the input features is used by default.  Coordinate System 
Code Sample
The following Python window script demonstrates how to use the AddGeometryAttributes tool.
import arcpy
arcpy.env.workspace = r"C:\data\City.gdb"
arcpy.AddGeometryAttributes_management("roads", "LENGTH;LINE_START_MID_END")
Get the extent rectangle of each line feature and build a 10 x 10 grid within that extent.
# Name: GridCreation.py
# import system modules
import arcpy
# Set environment settings
arcpy.env.workspace = r"C:\data\City.gdb"
arcpy.env.outputCoordinateSystem = arcpy.Describe("roads").spatialReference
# Set local variables
in_features = "roads"
properties = "EXTENT"
length_unit = ""
area_unit = ""
coordinate_system = ""
# Generate the extent coordinates using Add Geometry Properties tool
arcpy.AddGeometryAttributes_management(in_features, properties, length_unit,
area_unit,
coordinate_system)
# Use Search Cursor to walk through each feature and generate grids
with arcpy.da.SearchCursor(in_features, ["OID@", "EXT_MIN_X", "EXT_MIN_Y",
"EXT_MAX_X", "EXT_MAX_Y"]) as sCur:
for row in sCur:
minX, minY, maxX, maxY = row[1], row[2], row[3], row[4]
arcpy.CreateFishnet_management("fishnet_{0}".format(row[0]),
number_rows = 10,
number_columns = 10,
template = "{0} {1} {2} {3}".format(minX, maxX, minY, maxY),
origin_coord = "{0} {1}".format(minX, minY),
y_axis_coord = "{0} {1}".format(minX, maxY),
corner_coord = "{0} {1}".format(maxX, maxY),
geometry_type = "POLYGON",
labels = "NO_LABELS")