I am working on a python script that updates a field titled 'PlanRefID' field in several point feature classes. These are populated based on a 'PlanRefID' field in a polygon feature class. The cursor will loop through and populate the 'PlanRefID' field in the point feature classes (approximately 10) correctly.
The issue I am having is that I only want it to update where the PlanRefID IS NULL in my point feature classes. However, it will loop through all records in the polygon feature class, which is taking about 1.5 - 2 hours to run. As the feature classes add more records, the processing time will only increase. I only interested in updating the point features where the PlanRefID IS NULL and referencing the polygons they intersect.
arcpy.MakeFeatureLayer_management("Database Connections\\Server Database OWNER.sde\\Database.OWNER.FeatureDataset\\Database.OWNER.Polygon", "Database_OWNER_Polygon")
arcpy.MakeFeatureLayer_management("Database Connections\\Server Database OWNER.sde\\Database.OWNER.FeatureDataset\\Database.OWNER.Point", "Database_Owner_Point", "PlanRefID IS NULL")
arcpy.SelectLayerByAttribute_management("Database_Owner_Point", "NEW_SELECTION", "PlanRefID IS NULL")
rows = arcpy.SearchCursor("Database_OWNER_Polygon")
for row in rows:
arcpy.SelectLayerByAttribute_management("Database_OWNER_Polygon", "NEW_SELECTION", "\"OBJECTID\" = " + str(row.getValue("OBJECTID")))
arcpy.SelectLayerByLocation_management("Database_Owner_Point", "INTERSECT", "Database_OWNER_Polygon", "", "NEW_SELECTION")
arcpy.CalculateField_management("Database_Owner_Point", "PlanRefID", "'{0}'".format(str(row.getValue("PlanRefID"))), "PYTHON_9.3", "") print "Finished processing " + str(row.getValue("PlanRefID"))
Brian