Calculate Geometry Attributes (Data Management)

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

    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.

  • 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.

Syntax

arcpy.management.CalculateGeometryAttributes(in_features, geometry_property, {length_unit}, {area_unit}, {coordinate_system}, {coordinate_format})
ParameterExplanationData 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:

  • AREAThe area of each polygon feature.
  • AREA_GEODESICThe shape-preserving geodesic area of each polygon feature.
  • CENTROID_XThe centroid x-coordinate of each feature.
  • CENTROID_YThe centroid y-coordinate of each feature.
  • CENTROID_ZThe centroid z-coordinate of each feature.
  • CENTROID_MThe centroid m-coordinate of each feature.
  • INSIDE_XThe 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_YThe 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_ZThe 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_MThe 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_COUNTThe number of curves in each feature. Curves include elliptical arcs, circular arcs, and Bezier curves.
  • HOLE_COUNTThe number of interior holes within each polygon feature.
  • EXTENT_MIN_XThe minimum x-coordinate of each feature's extent.
  • EXTENT_MIN_YThe minimum y-coordinate of each feature's extent.
  • EXTENT_MIN_ZThe minimum z-coordinate of each feature's extent.
  • EXTENT_MAX_XThe maximum x-coordinate of each feature's extent.
  • EXTENT_MAX_YThe maximum y-coordinate of each feature's extent.
  • EXTENT_MAX_ZThe maximum z-coordinate of each feature's extent.
  • LENGTHThe length of each line feature.
  • LENGTH_GEODESICThe shape-preserving geodesic length of each line feature.
  • LENGTH_3DThe 3D length of each line feature.
  • LINE_BEARINGThe 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_XThe x-coordinate of the start point of each line feature.
  • LINE_START_YThe y-coordinate of the start point of each line feature.
  • LINE_START_ZThe z-coordinate of the start point of each line feature.
  • LINE_START_MThe m-coordinate of the start point of each line feature.
  • LINE_END_XThe x-coordinate of the end point of each line feature.
  • LINE_END_YThe y-coordinate of the end point of each line feature.
  • LINE_END_ZThe z-coordinate of the end point of each line feature.
  • LINE_END_MThe m-coordinate of the end point of each line feature.
  • PART_COUNTThe number of parts comprising each feature.
  • PERIMETER_LENGTHThe length of the perimeter or border of each polygon feature.
  • PERIMETER_LENGTH_GEODESICThe shape-preserving geodesic length of the perimeter or border of each polygon feature.
  • POINT_COUNTThe number of points or vertices comprising each feature.
  • POINT_XThe x-coordinate of each point feature.
  • POINT_YThe y-coordinate of each point feature.
  • POINT_ZThe z-coordinate of each point feature.
  • POINT_MThe m-coordinate of each point feature.
  • POINT_COORD_NOTATIONThe 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_USLength in feet (United States)
  • METERSLength in meters
  • KILOMETERSLength in kilometers
  • MILES_USLength in miles (United States)
  • NAUTICAL_MILESLength in nautical miles (United States)
  • YARDSLength in yards (United States)
String
area_unit
(Optional)

The unit used to calculate area.

  • ACRESArea in acres
  • HECTARESArea in hectares
  • SQUARE_MILES_USArea in square miles (United States)
  • SQUARE_KILOMETERSArea in square kilometers
  • SQUARE_METERSArea in square meters
  • SQUARE_FEET_USArea in square feet (United States)
  • SQUARE_YARDSArea in square yards (United States)
  • SQUARE_NAUTICAL_MILESArea 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_INPUTThe input features' spatial reference units are used for coordinate formatting. This is the default.
  • DDDecimal Degrees.
  • DMS_DIR_LASTDegrees Minutes Seconds with cardinal direction component at the end (DDD° MM' SSS.ss" <N|S|E|W>).
  • DMS_DIR_FIRSTDegrees Minutes Seconds with cardinal direction component at the beginning (<N|S|E|W> DDD° MM' SSS.ss").
  • DMS_POS_NEGDegrees Minutes Seconds with positive or negative direction component at the beginning (<+|-> DDD° MM' SSS.ss").
  • DMS_PACKEDDegrees Minutes Seconds packed into a single value with positive or negative direction component at the beginning (<+|-> DDD.MMSSSss).
  • DDM_DIR_LASTDegrees Decimal Minutes with cardinal direction component at the end (DDD° MM.mmm' <N|S|E|W>).
  • DDM_DIR_FIRSTDegrees Decimal Minutes with cardinal direction component at the beginning (<N|S|E|W> DDD° MM.mmm').
  • DDM_POS_NEGDegrees Decimal Minutes with positive or negative direction component at the beginning (<+|-> DDD° MM.mmm').
  • GARSThe Global Area Reference System is based on latitude and longitude, dividing and subdividing the world into cells.
  • GEOREFThe World Geographic Reference System is based on the geographic system of latitude and longitude, but using a simpler and more flexible notation.
  • MGRSMilitary Grid Reference System.
  • USNGUnited States National Grid.
  • UTMUniversal Transverse Mercator.
  • UTMNSUniversal Transverse Mercator with no spaces.
String

Derived Output

NameExplanationData Type
updated_features

The updated input features.

Feature Layer

Code sample

CalculateGeometryAttributes example (Python window)

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")
CalculateGeometryAttributes example (stand-alone script)

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"]])

Licensing information

  • Basic: Yes
  • Standard: Yes
  • Advanced: Yes

Related topics