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(outFClyr) for row in cur: buffarea = row.getValue(buffareafld) habarea = row.getValue(areafld) row.percentfld = (buffarea/habarea)*100 cur.updateRow(row) del cur, row
Signed in members can post, follow updates, and more. New here? Register a free account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.