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. Testing the code in the Python window in Desktop reveals that the running total is not behaving as I would expect (printing repeating values versus an increasing value).
tempPgs = "LayerName"sort_fields = [tempPgs, "DESCENDING"]
arcpy.AddField_management(tempPgs, "cumulative", "DOUBLE")
CursorFieldNames = ["SHAPE@","cumulative"]
with arcpy.da.UpdateCursor(tempPgs, CursorFieldNames) as cursor:
for row in cursor:
AreaValue = row.getArea('GEODESIC', 'ACRES') #Read area value as double
running += AreaValue #Capture running total
row = AreaValue #Write total area value plus the previously added values to field
del row, cursor #Clean up cursor objects