This question is similar to Copy a polygon geometry in Arcpy, except within the context of using Arcpy.da instead.
I want to copy the geometry from one feature class to another using ArcPy.da (I'm not concerned about attributes of the feature class right now).
I have a Python script that reads features from one feature class based upon a given WHERE clause using a search cursor and then inserts the features from the search cursor into another feature class:
import arceditor
import arcpy
inputfeatureclass = arcpy.GetParameterAsText(0)
insert_field = arcpy.GetParameterAsText(1)
where_field = arcpy.GetParameterAsText(2)
expression = arcpy.GetParameterAsText(3)
insertfeatureclass = arcpy.GetParameterAsText(4)
def get_specified_rows(inputfeatureclass, insert_field, where_field, expression):
searchcursor = arcpy.da.SearchCursor(inputfeatureclass, (insert_field, where_field), where_clause=expression)
return searchcursor
def insert_specified_rows(searchcursor, insertfeatureclass):
insertcursor = arcpy.da.InsertCursor(insertfeatureclass, ("SHAPE@"))
for row in searchcursor:
arcpy.AddMessage(row[0])
insertcursor.insertRow(row[0])
searchcursor = get_specified_rows(inputfeatureclass, insert_field, where_field, expression)
insert_specified_rows(searchcursor, insertfeatureclass)
The polygon Shape field is the value passed for my insert_field parameter.
The program fails on insertcursor.insertRow(row[0]) with the following error: sequence size must match size of the row.
I'm getting the following message on arcpy.AddMessage(row[0]): [3088680.146493972, 10159411.210196389].
This does not look like a polygon array, perhaps I am reading the polygon incorrectly using my search cursor?