dodgyshamrock

Error 999999 with Update Cursor - somebody please help!

Discussion created by dodgyshamrock on Nov 10, 2011
Latest reply on Dec 6, 2011 by miguel35
Could somebody please tell me what is going wrong with this program?  I keep getting an ERROR 999999 for the line with the cursor.  But I've checked my syntax, spelling, capitalization, etc. and I can't figure out why it won't work!! 

I am trying to loop through a list of feature classes, intersect each of them with a buffer polygon, and then join the tables for the resulting intersect layer with the buffer polygon table.  Then I need to set the "PERCENTAGE" field in each one to the bufferarea/habitat area * 100.  Since it is looping through the list of feature classes, I have to use variable names for the fields.  Is this what is clogging it up?

I have been struggling with this for a week!!!!

Hopefully this will keep the indentation, but here is the part of the program that is choking on the update cursor:


IntersectLyr = arcpy.MakeFeatureLayer_management(BufferPoly, "buffpolylyr")

fcList = arcpy.ListFeatureClasses("selfts_*", "Polygon")
for fc in fcList:
    desc = arcpy.Describe(fc)
    outFC = desc.baseName.strip("selfts_") + "_Intersect"
    in_features = [IntersectLyr, fc]
    #Perform Intersect between bufferpoly and selected features in each habitat feature class
    arcpy.Intersect_analysis(in_features, outFC)
    arcpy.AddField_management(outFC, "PERCENTAGE", "Double")
    des = arcpy.Describe(outFC)
    outFClyr = des.baseName + "lyr"
    arcpy.MakeFeatureLayer_management(outFC, outFClyr)
    arcpy.AddMessage("The Intersect Layer is: " + str(outFClyr))
    arcpy.AddJoin_management(outFClyr, "FID_ProjectRadius", IntersectLyr, "OBJECTID")
    fldList = arcpy.ListFields(outFClyr, "*.PERCENTAGE")
    for fld in fldList:
        percentfld = fld.name
        arcpy.AddMessage(fld.name)
    fldList2 = arcpy.ListFields(outFClyr, "*.Shape_Area")
    for fld in fldList2:
        if fld.name == "ProjectRadius.Shape_Area":
            arcpy.AddMessage(fld.name)
            buffareafld = fld.name
        else:
            arcpy.AddMessage(fld.name)
            areafld = fld.name
    cur = arcpy.UpdateCursor(Intersect)
    for row in cur:
        buffarea = row.getValue(buffareafld)
        habarea = row.getValue(areafld)
        row.percentfld = (buffarea/habarea)*100
        cur.updateRow(row)

del cur, row

A multitude of thanks in advance to anyone who can help!!

Amy Meehan
Maine Dept. Inland Fisheries and Wildlife

Outcomes