## Summary

Adds information to a feature's attribute fields representing the spatial or geometric characteristics and location of each feature, such as length or area and x-, y-, z-, and m-coordinates.

A similar tool that adds multiple geometry attributes to new attribute fields is the Add Geometry Attributes tool.

## Usage

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.

If the input features have a selection, only the selected features will have values calculated in the added fields; all other features will maintain their existing value.

This tool works with point, multipoint, polyline, and polygon feature classes.

##### Caution:

This tool modifies the input data. See Tools that modify or update the input data for more information and strategies to avoid undesired data changes.

## Syntax

arcpy.management.CalculateGeometryAttributes(in_features, geometry_property, {length_unit}, {area_unit}, {coordinate_system}, {coordinate_format})

Parameter | Explanation | Data Type |

in_features | The feature layer with a field that will be updated with geometry calculations. | Feature Layer |

geometry_property [[Target Field, Property],...] | Specifies the fields in which to calculate geometry properties and the geometry properties to calculate. The following are supported geometry properties: - AREA —The area of each polygon feature.
- AREA_GEODESIC —The shape-preserving geodesic area of each polygon feature.
- CENTROID_X —The centroid x-coordinate of each feature.
- CENTROID_Y —The centroid y-coordinate of each feature.
- CENTROID_Z —The centroid z-coordinate of each feature.
- CENTROID_M —The centroid m-coordinate of each feature.
- INSIDE_X —The x-coordinate of a central point inside or on each feature. This point is the same as the centroid if the centroid is inside the feature; otherwise, it is an inner label point.
- INSIDE_Y —The y-coordinate of a central point inside or on each feature. This point is the same as the centroid if the centroid is inside the feature; otherwise, it is an inner label point.
- INSIDE_Z —The z-coordinate of a central point inside or on each feature. This point is the same as the centroid if the centroid is inside the feature; otherwise, it is an inner label point.
- INSIDE_M —The m-coordinate of a central point inside or on each feature. This point is the same as the centroid if the centroid is inside the feature; otherwise, it is an inner label point.
- CURVE_COUNT —The number of curves in each feature. Curves include elliptical arcs, circular arcs, and Bezier curves.
- HOLE_COUNT —The number of interior holes within each polygon feature.
- EXTENT_MIN_X —The minimum x-coordinate of each feature's extent.
- EXTENT_MIN_Y —The minimum y-coordinate of each feature's extent.
- EXTENT_MIN_Z —The minimum z-coordinate of each feature's extent.
- EXTENT_MAX_X —The maximum x-coordinate of each feature's extent.
- EXTENT_MAX_Y —The maximum y-coordinate of each feature's extent.
- EXTENT_MAX_Z —The maximum z-coordinate of each feature's extent.
- LENGTH —The length of each line feature.
- LENGTH_GEODESIC —The shape-preserving geodesic length of each line feature.
- LENGTH_3D —The 3D length of each line feature.
- LINE_BEARING —The start-to-end bearing of each line feature. Values range from 0 to 360, with 0 meaning north, 90 east, 180 south, 270 west, and so on.
- LINE_START_X —The x-coordinate of the start point of each line feature.
- LINE_START_Y —The y-coordinate of the start point of each line feature.
- LINE_START_Z —The z-coordinate of the start point of each line feature.
- LINE_START_M —The m-coordinate of the start point of each line feature.
- LINE_END_X —The x-coordinate of the end point of each line feature.
- LINE_END_Y —The y-coordinate of the end point of each line feature.
- LINE_END_Z —The z-coordinate of the end point of each line feature.
- LINE_END_M —The m-coordinate of the end point of each line feature.
- PART_COUNT —The number of parts comprising each feature.
- PERIMETER_LENGTH —The length of the perimeter or border of each polygon feature.
- PERIMETER_LENGTH_GEODESIC —The shape-preserving geodesic length of the perimeter or border of each polygon feature.
- POINT_COUNT —The number of points or vertices comprising each feature.
- POINT_X —The x-coordinate of each point feature.
- POINT_Y —The y-coordinate of each point feature.
- POINT_Z —The z-coordinate of each point feature.
- POINT_M —The m-coordinate of each point feature.
- POINT_COORD_NOTATION —The x- and y-coordinate of each point feature formatted as a specified coordinate notation.
| Value Table |

length_unit (Optional) | The unit used to calculate length. - FEET_US —Length in feet (United States)
- METERS —Length in meters
- KILOMETERS —Length in kilometers
- MILES_US —Length in miles (United States)
- NAUTICAL_MILES —Length in nautical miles (United States)
- YARDS —Length in yards (United States)
| String |

area_unit (Optional) | The unit used to calculate area. - ACRES —Area in acres
- HECTARES —Area in hectares
- SQUARE_MILES_US —Area in square miles (United States)
- SQUARE_KILOMETERS —Area in square kilometers
- SQUARE_METERS —Area in square meters
- SQUARE_FEET_US —Area in square feet (United States)
- SQUARE_YARDS —Area in square yards (United States)
- SQUARE_NAUTICAL_MILES —Area in square nautical miles (United States)
| 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. For coordinate-based geometry properties, the coordinate system will only be applied when the coordinate format is the same as input; otherwise, the geographic coordinate system WGS_1984 will be used. | Coordinate System |

coordinate_format (Optional) | The coordinate format in which the x- and y-coordinates will be calculated. The coordinate format matching the input features' spatial reference units is used by default. Several coordinate formats, including Degrees Minutes Seconds, Degrees Decimal Minutes, and others, require the calculation to be performed in a text field. - SAME_AS_INPUT —The input features' spatial reference units are used for coordinate formatting. This is the default.
- DD —Decimal Degrees.
- DMS_DIR_LAST —Degrees Minutes Seconds with cardinal direction component at the end (DDD° MM' SSS.ss" <N|S|E|W>).
- DMS_DIR_FIRST —Degrees Minutes Seconds with cardinal direction component at the beginning (<N|S|E|W> DDD° MM' SSS.ss").
- DMS_POS_NEG —Degrees Minutes Seconds with positive or negative direction component at the beginning (<+|-> DDD° MM' SSS.ss").
- DMS_PACKED —Degrees Minutes Seconds packed into a single value with positive or negative direction component at the beginning (<+|-> DDD.MMSSSss).
- DDM_DIR_LAST —Degrees Decimal Minutes with cardinal direction component at the end (DDD° MM.mmm' <N|S|E|W>).
- DDM_DIR_FIRST —Degrees Decimal Minutes with cardinal direction component at the beginning (<N|S|E|W> DDD° MM.mmm').
- DDM_POS_NEG —Degrees Decimal Minutes with positive or negative direction component at the beginning (<+|-> DDD° MM.mmm').
- GARS —The Global Area Reference System is based on latitude and longitude, dividing and subdividing the world into cells.
- GEOREF —The World Geographic Reference System is based on the geographic system of latitude and longitude, but using a simpler and more flexible notation.
- MGRS —Military Grid Reference System.
- USNG —United States National Grid.
- UTM —Universal Transverse Mercator.
- UTMNS —Universal Transverse Mercator with no spaces.
| String |

#### Derived Output

Name | Explanation | Data Type |

updated_features | The updated input features. | Feature Layer |

## Code sample

The following Python window script demonstrates how to use the CalculateGeometryAttributes tool.

```
import arcpy
arcpy.env.workspace = r"C:\data\City.gdb"
arcpy.CalculateGeometryAttributes_management("roads", [["Length_mi", "LENGTH"], ["Stops", "POINT_COUNT"]], "MILES_US")
```

Get the extent rectangle of each feature.

```
# Name: ExtentCreation.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"
# Generate the extent coordinates using CalculateGeometry
arcpy.CalculateGeometryAttributes_management(in_features, [["Left", "EXTENT_MIN_X"],
["Bottom", "EXTENT_MIN_Y"],
["Right", "EXTENT_MAX_X"],
["Top", "EXTENT_MAX_Y"]])
```

## Environments

## Licensing information

- Basic: Yes
- Standard: Yes
- Advanced: Yes