2

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]) 
  • 4
    Change iCursor.insertRow([row,aValue]) to iCursor.insertRow([row[0],aValue]). – fatih_dur Dec 7 '16 at 7:16
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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.