Add Geometry Attributes (Data Management)

License Level:BasicStandardAdvanced

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 m-coordinates.

Usage

Syntax

AddGeometryAttributes_management (Input_Features, Geometry_Properties, {Length_Unit}, {Area_Unit}, {Coordinate_System})
ParameterExplanationData 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 m-coordinates.

Feature Layer
Geometry_Properties
[Geometry_Properties,...]

Determines the geometry or shape properties that will be calculated into new attribute fields.

  • AREAAdds an attribute to store the area of each polygon feature.
  • AREA_GEODESICAdds an attribute to store the geodesic area of each polygon feature.
  • CENTROIDAdds attributes to store the centroid coordinates of each feature.
  • CENTROID_INSIDEAdds attributes to store the coordinates of a central point inside or on each feature.
  • EXTENTAdds attributes to store the extent coordinates of each feature.
  • LENGTHAdds an attribute to store the length of each line feature.
  • LENGTH_GEODESICAdds an attribute to store the geodesic length of each line feature.
  • LENGTH_3DAdds an attribute to store the 3D length of each line feature.
  • LINE_BEARINGAdds an attribute to store 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_MID_ENDAdds attributes to store the coordinates of the start, mid, and end points of each feature.
  • PART_COUNTAdds an attribute to store the number of parts comprising each feature.
  • PERIMETER_LENGTHAdds an attribute to store the length of the perimeter or border of each polygon feature.
  • PERIMETER_LENGTH_GEODESICAdds an attribute to store the geodesic length of the perimeter or border of each polygon feature.
  • POINT_COUNTAdds an attribute to store the number of points or vertices comprising each feature.
  • POINT_X_Y_Z_MAdds attributes to store the x-, y-, z-, and m-coordinates of each point feature.
String
Length_Unit
(Optional)

The unit in which 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 in which 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

AddGeometryAttributes example (Python window)

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

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

Environments

Related Topics

Licensing Information

ArcGIS for Desktop Basic: Yes
ArcGIS for Desktop Standard: Yes
ArcGIS for Desktop Advanced: Yes
5/7/2015