Friday, May 20, 2011

Get the Geometry Field

In order to work with geometry in python you need to first get the geometry field. To do that, use the Describe():

import arcpy
fc = r"c:\temp\feature.shp"
desc = arcpy.Describe(fc)
geomField = desc.shapeFieldName


To read the geometry use a search cursor to access the row's geometry field

rows = arcpy.SearchCursor(fc)
for row in rows:
   feat = row.getValue(geomField)
   # do something
del rows, row


Use the getPart() function to get dig into the actual geometry object.

Enjoy

No comments: