Hello Jeff,
Thank so much for the quick reply!
import arcpy
arcpy.env.overwriteOutput = True
arcpy.env.workspace = r"I:\Workspace.gdb"
arcpy.MakeFeatureLayer_management (r"I:\Workspace.gdb\AddressMaster", "lyr_address")
arcpy.SelectLayerByAttribute_management ("AddressMaster", "NEW_SELECTION", "STRT_NAM IS NULL")
# -------------------- Quadrant Codes --------------------
arcpy.SelectLayerByAttribute_management ("AddressMaster", "NEW_SELECTION", "STRT_NAM IS NULL")
arcpy.MakeFeatureLayer_management(r"I:\Workspace.gdb\AddressQuad", "lyr_addressquad")
rows = arcpy.SearchCursor("lyr_addressquad")
for row in rows:
arcpy.SelectLayerByAttribute_management("lyr_addressquad", "NEW_SELECTION", "\"OBJECTID \" = " + str(row.getValue("OBJECTID")))
arcpy.SelectLayerByLocation_management("lyr_address", "INTERSECT", "lyr_addressquad", "", "NEW_SELECTION")
arcpy.CalculateField_management("lyr_address", "Quadrant", "'{0}'".format(str(row.getValue("Quadrant"))), "PYTHON_9.3", "")
# -------------------- ZIP Codes --------------------
arcpy.MakeFeatureLayer_management(r"I:\Workspace.gdb\ZIPCode2021", "lyr_ZIPcodes")
rows = arcpy.SearchCursor("lyr_ZIPcodes")
for row in rows:
arcpy.SelectLayerByAttribute_management("lyr_ZIPcodes", "NEW_SELECTION", "\"OBJECTID \" = " + str(row.getValue("OBJECTID")))
arcpy.SelectLayerByLocation_management("lyr_address", "INTERSECT", "lyr_ZIPcodes", "", "NEW_SELECTION")
arcpy.CalculateField_management("lyr_address", "ZIP", "'{0}'".format(str(row.getValue("ZCTA5CE"))), "PYTHON_9.3", "")
# -------------------- UGA Areas --------------------
arcpy.MakeFeatureLayer_management(r"I:\Workspace.gdb\UGA", "lyr_UGA")
with arcpy.da.SearchCursor("lyr_UGA", ['SHAPE@', 'Jurisdiction']) as sCur:
for row in sCur:
select_geometry = row[0]
selected = arcpy.SelectLayerByLocation_management("lyr_UGA", "INTERSECT", "lyr_address", "", select_geometry, "NEW_SELECTION")
# check if there was a selection and assign the parcel_id or No
val = str(row[1]) if int(arcpy.GetCount_management(selected).getOutput(0))> 0 else 'No'
arcpy.CalculateField_management(selected, "UGA", "'{0}'".format(val), "PYTHON_9.3", "")
# -------------------- Parcel ID --------------------
arcpy.MakeFeatureLayer_management("I:\Workspace.gdb\ParcelsAndAssess", "lyr_parcels")
arcpy.SelectLayerByAttribute_management ("AddressMaster", "NEW_SELECTION", '"STRT_NAM" is Null')
with arcpy.da.SearchCursor(Parcel, ['SHAPE@', 'ParcelID']) as sCur:
for row in sCur:
select_geometry = row[0]
selected = arcpy.SelectLayerByLocation_management("lyr_address", "INTERSECT", "lyr_parcels", "1", select_geometry, "NEW_SELECTION")
arcpy.CalculateField_management(selected, "Parcel_ID", "'{0}'".format(str(row[1])), "PYTHON_9.3", "")
There seems to be two things possibly causing this. When I removed the .da. from rows = arcpy.SearchCursor from Quadrant and Zip, those codes began working normally. The other is when I try to run the Parcel selection code or UGA with select_geometry, it causes the following error. The moment I remove that, it runs again but back to being really slow or as stated below for UGA.
arcgisscripting.ExecuteError: ERROR 000622: Failed to execute (Select Layer By Location). Parameters are not valid.
ERROR 000800: The value is not a member of INVERT | NOT_INVERT.
For UGA, I moved the select_geometry over as seen below but then it was pulling the wrong UGA zone but at least this time it ran without erroring.
with arcpy.da.SearchCursor("lyr_UGA", ['SHAPE@', 'Jurisdiction']) as sCur:
for row in sCur:
select_geometry = row[0]
arcpy.SelectLayerByLocation_management(select_geometry, "INTERSECT", "lyr_address", "", "NEW_SELECTION")
val = str(row[1]) if int(arcpy.GetCount_management(selected).getOutput(0))> 0 else 'No'
arcpy.CalculateField_management("lyr_address", "UGA", "'{0}'".format(val), "PYTHON_9.3", "")
I feel like its really close and I am just horrible with python and missing something.