I am trying to update an existing field in a polygon fc with an existing field in a point fc. There is only ever one point fc located within each polygon fc. The field names in the polygon fc can not change as it needs to have a matching schema for a later append.
Lotnumber is the point fc while fcUpdate is the polygon fc in the below code. I was trying to create a search cursor that would iterate through each point and store the value in the TEXTSTRING field. the code should then select the polygon that contains the current point, insert an update cursor, and update the Housenumber field with the value obtained from the point.
# Enter the point feature class containing lot numbers
Lotnumber = arcpy.GetParameterAsText(4)
# Make a layer from previously created new feature class
# open a search cursor to iterate through each point
with arcpy.SearchCursor(Lotnumber, "TEXTSTRING") as cursor1:
# Iterate through each point in the point fc
for row in cursor1:
lotnum = row.getValue("TEXTSTRING")
# Select the parcel that contains the point
parcel = arcpy.SelectLayerByLocation_management(fcUpdate, "COMPLETELY_CONTAINS", row)
cursor2 = arcpy.da.UpdateCursor(parcel, 'HouseNumber')
for row in cursor2:
row = lotnum
# delete the cursor
My code is based on a question answered here: Using Select By Location to update field in feature class using ArcPy?
I'm very new to Python. I've tried running the script in ArcMap and get an error stating invalid SQL statements were used.