Geographic Information Systems Asked on July 27, 2021
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?
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."
Correct answer by Barbarossa on July 27, 2021
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")
Answered by Kingsley Esezobor on July 27, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP