4

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]) 
Rodri
3472 silver badges12 bronze badges
asked Dec 7, 2016 at 6:46
1
  • 4
    Change iCursor.insertRow([row,aValue]) to iCursor.insertRow([row[0],aValue]). Commented Dec 7, 2016 at 7:16

1 Answer 1

3

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.

answered Dec 7, 2016 at 22:56

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.