To update values in a feature class within a geodatabase using acrpy, we can use an Update Cursor.
Using an Update Cursor
You can use an arcpy.da.UpdateCursor
to iterate through the rows of your feature class and update specific fields. Here is an example:
import arcpy
# Set the workspace (geodatabase path)
arcpy.env.workspace = r"C:\path\to\your\geodatabase.gdb"
# Define the feature class
feature_class = "FeatureClassName"
# Define the field names you want to update
field_to_update = "FieldName"
# Update the field values
with arcpy.da.UpdateCursor(feature_class, field_to_update) as cursor:
for row in cursor:
# Modify the value as needed
row[0] = "New Value"
# This line is very important
cursor.updateRow(row)
print("Field values updated successfully!")
标签:999,update,Update,values,feature,geodatabase,arcpy,class
From: https://www.cnblogs.com/alex-bn-lee/p/18205458