I am using Desktop 10.6, Basic license, Spatial Analyst, Python 2.6, 2019 AD.
I have 4 overlapping features in a polygon feature class. I'd like to sort the features by the depth field, calculate the acreage for the largest depth, then move to the next depth, calculate its acreage and then add it to the previous depth, and so on. This code currently does not work past adding the cumulative field. In the attached photo, the cumulative depth is what I am trying to generate. The acres field is to show the progression.
Working code:
contours = arcpy.GetParameterAsText(0) desc = arcpy.Describe(contours) arcpy.env.workspace = desc.path arcpy.AddField_management(contours, "Cumulative_AC", "DOUBLE") arcpy.AddField_management(contours, "Acres", "DOUBLE") CursorFieldNames = ["SHAPE@", "Cumulative_AC", "Acres"] RunTl = 0 with arcpy.da.UpdateCursor(contours, CursorFieldNames, sql_clause=(None, 'ORDER BY DEPTH DESC')) as cursor: for row in cursor: AreaValue = row[0].getArea('GEODESIC', 'ACRES') # Read area value as double RunTl += AreaValue # Capture running total row[1] = RunTl # Write total area value plus the previously added values to field row[2] = AreaValue cursor.updateRow(row) del RunTl 