Skip To Content

Calculate Geometry Attributes

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 theAdd Geometry Attributes tool.

Usage

    Caution:

    This tool modifies the input data. See Tools that do not create output datasets 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

CalculateGeometryAttributes_management (in_features, geometry_property, {length_unit}, {area_unit}, {coordinate_system})
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.
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.

Coordinate System

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

  • ArcGIS Desktop Basic: Yes
  • ArcGIS Desktop Standard: Yes
  • ArcGIS Desktop Advanced: Yes

Related topics