<type 'exceptions.NameError'>: name 'line' is not defined Failed to execute (RCW 3 Mile).
#Select out each parcel record one by one and evalauate how many cluster buffers intersect with that parcel. #Update Parcel Attribute Table field three_mi with the # of buffers that intersect that parcel SelectedParcelsFL=arcpy.GetParameterAsText(0) CbuffersFL=arcpy.GetParameterAsText(1) #make sure that no records are currently selected in either slected parclesFL or cBuffersFL arcpy.AddMessage("Clearing selected parcel selections\n") arcpy.SelectLayerByAttribute_management(SelectedParcelsFL,"CLEAR_SELECTION") arcpy.AddMessage("Clearing selected buffer selections\n") arcpy.SelectLayerByAttribute_management(CbuffersFL,"CLEAR_SELECTION") #Now begin 3-mile disperal buffer count print "updating parcels table with the number of 3-mile RCW dispersal buffers that intersect each parcel" arcpy.AddMessage("updating parcels table with the number of 3-mile RCW dispersal buffers that intersect each parcel\n") for parcel in range(0,1092): FID = "FID=%s" % (parcel) arcpy.SelectLayerByAttribute_management(SelectedParcelsFL,"NEW_SELECTION",FID) arcpy.SelectLayerByLocation_management(CbuffersFL,"INTERSECT",SelectedParcelsFL) bufferCount = int(arcpy.GetCount_management(CbuffersFL).getOutput(0)) arcpy.AddMessage(str(FID)+" has "+str(bufferCount)+" RCW 3-mile dispersal buffers that intersect with it.") #Update the three_mi field uc=arcpy.UpdateCursor(SelectedParcelsFL) for line in uc: line.three_mi = bufferCount uc.updateRow(line) #Actually changes the table values to buffer count del line, uc arcpy.SelectLayerByAttribute_management(SelectedParcelsFL,"CLEAR_SELECTION") print "updating parcels table with the number of 3-mile RCW dispersal buffers that intersect each parcel COMPLETED" arcpy.AddMessage("updating parcels table with the number of 3-mile RCW dispersal buffers that intersect each parcel COMPLETED")
Solved! Go to Solution.