I'm trying to insert geometries from one feature class into another and then update an attribute associated with the geometry. Only inserting the geometry works fine, but I can't work out how to insert the new value associated with the geometry. Below insertRow() gives 'TypeError: cannot read geometry sequence'.
import arcpy
aLayer = arcpy.GetParameterAsText(0)
aValue = arcpy.GetParameterAsText(1)
target = "C:\\local.gdb\\target"
desc = arcpy.Describe(aLayer)
type = desc.shapeType
if type == "Polygon":
with arcpy.da.InsertCursor(target, ["SHAPE@","aField"]) as iCursor:
with arcpy.da.SearchCursor(aLayer, ["SHAPE@"]) as sCursor:
for row in sCursor:
iCursor.insertRow([row,aValue])
1 Answer 1
You are trying to insert a row object within a row object in place of the SHAPE@
field/attribute. From your search cursor, you need to specify the index of your to-be-copied attribute value, which takes place at row[0].
Therefore, changing iCursor.insertRow([row,aValue])
to iCursor.insertRow([row[0],aValue])
will resolve your problem.
iCursor.insertRow([row,aValue])
toiCursor.insertRow([row[0],aValue])
.