import arcpy from arcpy import env env.workspace = r"C:\temp\python\test.gdb" env.overwriteOutput = True fc1 = "DevelopmentSites" fc2 = "FloodPlain" # Add field to DevelopmentSites arcpy.AddField_management(fc1, "Percentage", "Double") # Perform an intersect between DevelopmentSites & FloodPlain feature classes arcpy.Intersect_analysis([[fc1], [fc2]], "Intersect") # Join intersecting feature class with DevelopmentSites arcpy.MakeFeatureLayer_management(fc1, "development_layer") arcpy.AddJoin_management("development_layer", "OBJECTID", "Intersect", "FID_DevelopmentSites") # Calculate Percentage of flood plain coverage arcpy.CalculateField_management("development_layer", "DevelopmentSites.Percentage", "!Intersect.Shape_Area! / !DevelopmentSites.Shape_Area! * 100", "PYTHON") # Delete Intersect feature class arcpy.Delete_management("Intersect")
import arcpy, time from operator import itemgetter arcpy.Clip_analysis('theData', 'buffer500', 'clip500') # define dictionary summary = dict() rows = arcpy.SearchCursor('clip500') # type or category is in my feature class called DESCRIPTION. for row in rows: if row.DESCRIPTION in summary: summary[row.DESCRIPTION] = summary[row.DESCRIPTION] + row.shape_area else: summary[row.DESCRIPTION] = row.shape_area # dictionary now loaded, from here on out are simply acreage conversions, sorting. sumTotalAc = sum(summary.values())/43560.0 arcpy.AddMessage('\nTotal area: ' + str(sumTotalAc)) sortSummaryAc = sorted(([a, b/43560.0] for a, b in summary.iteritems()), key = itemgetter(1), reverse = True) arcpy.AddMessage(sortSummaryAc)
for each in sortSummaryAc: testgrab = elmhndl.pop() if round(each[1], 1) > 0.0: # here's the line adding both the acreage and percentage testgrab.text = each[0] + ' - ' + str(round(each[1], 1)) + ' acres (' + str(round((each[1]/sumTotalAc*100), 1)) + ' %)' index = assign(testgrab, [initPosX, initPosY]) initPosY = initPosY - float(0.2122) else: arcpy.AddMessage('\n...' + each[0] + ' is too small, removing element to remaining set...') testgrab.text = '-' index = assign(testgrab, [initPosX1, initPosY1])
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.