I originally asked UpdateCursor can't acquire lock, but can acquire lock in TestSchemaLock and got some help about why my code wasn't acquiring a lock.
My new problem is that my code isn't fully iterating, and I'm not sure why. My intention is that when I select each buffer used for clipping, I want the buffer to run a clip, create a clip output with that name, add and calculate fields, and then move on to create the next clip. There are 27 buffers (buff_id numbered 1 through 27), so that each clip output should be called "LS[buff_id]". It runs through LS1 just fine, giving me exactly what I expect, with the fields calculated, but then it doesn't move on to buff_id 2 to give me LS2 and so on.
What am I doing wrong?
Here's the code I'm using now:
import arcpy import os.path arcpy.env.workspace = "C:/Users/melis/Documents/HenryWork.gdb" arcpy.env.overwriteOutput = True buffer = "LS_buffer" landcov = "ForestLC_clip" #create list to access table. may need to change field name with other data. builds a list of all buff_id values. AllBuffID = [r for r in arcpy.da.SearchCursor(buffer, ["buff_id"])] for thisBuffID in AllBuffID: #select one buffer query = """ "buff_id" = %s """ %thisBuffID arcpy.SelectLayerByAttribute_management(buffer, "NEW_SELECTION", query) #define clip out path clip_out = "LS" + str(thisBuffID) #clip w one buffer arcpy.Clip_analysis(landcov, buffer, clip_out) #add fields to clip_out arcpy.AddField_management(clip_out, "clip_id", "TEXT", 20) arcpy.AddField_management(clip_out, "area_ha", "FLOAT") #create updatecursor for new clip_out with arcpy.da.UpdateCursor(clip_out, ["clip_id", "area_ha","SHAPE@"]) as clipCursor: for polys in clipCursor: #calc geom for area ha, project to UTM and calculate from the area polys = (polys.area) / 10000 #A hectare is 10000 square metres #field calc for buffer id polys = thisBuffID clipCursor.updateRow(polys) #IMPORTANT commit the update