I need to update the PrivateRoads 'Owner' field based on what city the private road is in. I have the following but it take for ever but doesn't populate the correct city. I know I can do a spatial join but I don't want to create a separate layer.
import sys, os, arcpy
import arcpy
## Works in file geodatabase
arcpy.env.overwriteOutput = True
workspace = "C:/temp/temp.gdb"
PR = "PrivateRoads"
CityLimits = 'City_Limits'
arcpy.MakeFeatureLayer_management(PR, "polyLyr")
arcpy.MakeFeatureLayer_management(CityLimits, "CitLyr")
with arcpy.da.UpdateCursor(PR, ['SHAPE@', 'OID@', 'Owner']) as cursor:
for row in cursor:
arcpy.management.SelectLayerByLocation("polyLyr", "HAVE_THEIR_CENTER_IN", "CitLyr", "", "NEW_SELECTION")
with arcpy.da.SearchCursor("CitLyr", ['CITY']) as cCursor:
for cRow in cCursor:
row[2] = cRow[0]
cursor.updateRow(row)