HOW TO
Adding features to a feature class can be done within an ArcGIS Pro editing session as described in the following documentation, ArcGIS Pro: Get started editing. It is also possible to add features outside of a Pro editing session using the insertCursor() ArcPy function. The function can be used as an object to insert the values for the newly created rows.
Note: The InsertCursor() function can also be used in conjunction with the SearchCursor() function to replicate certain fields.
import arcpy
row_values = [('<VALUE1>', (<X1>, <Y1>)), ('<VALUE2>', (<X2>, <Y2))]
cursor = arcpy.da.InsertCursor(r"C:/folder/geodatabase.gdb/feature", ("NAME", "SHAPE@XY"))
for row in row_values: cursor.insertRow(row)
del cursor
The following script demonstrates the full working code.
import arcpy # A list of values that will be used to construct new rows row_values = [('Atascosa', (1409934.4442000017, 1076766.8192000017)), ('Bosque', (752000.2489000037, 1128929.8114))] # Open an InsertCursor. # Specify the location for the desired feature. The sample inserts the values into the field, NAME and SHAPE. cursor = arcpy.da.InsertCursor(r"C:/data/texas.gdb/counties", ("NAME", "SHAPE@XY")) # Insert new rows that include the county name and the x and y coordinate # pair that represents the county center for row in row_values: cursor.insertRow(row) # Delete cursor object del cursor
To add data from another feature class, the SearchCursor() function must be used with the InsertCursor() function. The following script demonstrates the use of the SearchCursor() and the InsertCursor() functions. More fields can be added into the "<Field_Name>" section of the script.
import arcpy sourceCursor = arcpy.da.SearchCursor(r"<feature_path>", ("<Field_Name>", "SHAPE@XYZ")) inputCursor = arcpy.da.InsertCursor(r"<new_feature_path>", ("<Field_Name>", "SHAPE@XYZ")) for row in sourceCursor: inputCursor.insertRow(row) del inputCursor del sourceCursor
Article ID: 000031657
Get help from ArcGIS experts
Download the Esri Support App