3

Is there a way to copy a selected feature into an existing feature class?

Sort of like append would do, but only the selected features.

I want to iterate through a table and select features with a matching attribute in a feature class and copy that selected feature into an existing feature class.

Basically, it'd be like selected a feature in ArcMap and copying and pasting it into a different feature class.

Is this possible?

7

You can create a layer of selected features with make feature layer tool and then use the append tool.

"Map layers can be used as Input Datasets. If a layer has a selection, only the selected records (features or table rows) are used by the Append tool."

0
-1

If you want to use an input feature to update an existing feature this code will help do that. I you want to insert that will be another code entirely. Let me know if this is what you want

fc1 = "input_feature"
fc2 = "existing_feature"



with arcpy.da.SearchCursor(fc1, ["input_field","input_field"]) as cursor:
    for row in cursor:
        SQL_stat = "input_field = " +str(row[0])
        with arcpy.da.UpdateCursor(fc2, ["input_field", "existing_field"], SQL_stat) as cursor1:
            for row1 in cursor1:
                row1[1] = row[1]
                cursor1.updateRow(row1)
print("Done")
1
  • Two problems: This would only work if Layer object exists with the name "input_feature" (since the requirement is to work on a selection set), and UpdateCursor.updateRow() doesn't do an INSERT operation, InsertCursor does. Append on a layer selection set (as in the accepted answer) would be way faster, as well.
    – Vince
    Jul 27 at 20:55

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