Show Navigation | Hide Navigation
You are here:
Geoprocessing > Automating your work with scripts > Data properties and access when scripting

The geometry object

Release 9.2
Last modified January 9, 2007
E-mail This Topic Printable Version Give Us Feedback

Print all topics in : "Data properties and access when scripting"

Related Topics

Using a geometry object, the geoprocessor supports cursor access of feature geometry. The object, created by the row object when the Shape field is specified, exposes a number of properties that describe a feature. The example below shows how to create a geometry object for each line feature in a feature class and sum their length:

# Create search cursor
rows = gp.SearchCursor("D:/St_Johns/data.gdb/roads")
row = rows.Next()
# Calculate the total length of all roads
length = 0
while row:
    # Create the geometry object
    feat = row.shape
    length = length + feat.Length
    row = rows.Next()
print length

The geometry object

Type Null, point, multipoint, line, circulararc, ellipticarc, bezier3curve, path, polyline, ring, polygon, envelope, any, bag, multiPatch, triangleStrip, triangleFan, ray, sphere.
Extent XMin; YMin; XMax; YMax.
Centroid Returns the true centroid if it is within or on the feature, otherwise the label point is returned.
TrueCentroid The center of gravity for a feature.
LabelPoint The point at which the label is located. The LabelPoint is always located within or on a feature.
FirstPoint The first coordinate of the feature.
LastPoint The last coordinate of the feature.
Area The area of a polygon. Empty for all other feature types.
Length The length of the linear feature. Empty for point, multipoint feature types.
IsMultipart True, if the number of parts for this geometry is more than one.
PartCount The number of geometry parts for the feature.
HullRectangle The coordinate pairs of the convex hull rectangle.
GetPart(optional index) Returns an array of point objects for a particular part of geometry or an array containing a number of arrays, one for each part.

All simple feature classes require a geometry type field. It contains the actual geometry of a feature and is typically called Shape. The ListFields or Describe methods may be used to retrieve the geometry field from a feature class. The name of the field can be determined from the field object.

Learn more about reading geometries

Please visit the Feedback page to comment or give suggestions on ArcGIS Desktop Help.
Copyright © Environmental Systems Research Institute, Inc.