When a Table/FeatureClass is queried using ArcPy a cursor is used, you can bring just the fields required, but sometimes it is required the whole set of fields, and "*" can be used:
with arcpy.da.UpdateCursor(table, "*", where_clause=wc) as cursor:
It is needed to know which field holds the geometry. In this case is not possible to use a token because ALL the fields are required.
The following implementation was tested:
with arcpy.da.UpdateCursor(table, "*", where_clause=wc) as cursor:
shape_index = cursor.fields.index("Shape")
for row in cursor:
my_geometry = row[shape_index]
but it was found that geometry field can have other names aside "Shape".
[Edit]: arcpy package name added to the code
1 Answer 1
You can get the the geometry field name using the Describe function.
geometry_field_name = arcpy.Describe(table).shapeFieldName
shape_index = cursor.fields.index(geometry_field_name)
UpdateCursor
syntax isn't valid. It's always better to specify an explicit column list, since you can then always know which field is which.with arcpy.da.UpdateCursor(...
. If you've done something withimport
to make what you have valid, it should be included in the code block.