It seems your code sums the area covered by the polygons.
Instead of relying on a field that may or may not exist, and may or may not be correct you can get the area of the shapes at runtime:
Assuming that the feature class is in an appropriate spatial reference to sum the area:
def MySub(TotalArea1):
TotalArea = 0.0
with arcpy.da.SearchCursor(feat,"SHAPE@AREA") as sCur:
for Row in sCur:
TotalArea += Row[0]
with arcpy.da.UpdateCursor(feat,"TotArea") as uCur:
for Row in uCur:
Row[0] = TotalArea
If not, say your data is in geographic coordinates and you want to sum in metres (or feet) simply project-on-the-fly:
def MySub(TotalArea1):
TotalArea = 0.0
toSR = arcpy.SpatialReference(28355) # MGA55, find a SRID that suits you
with arcpy.da.SearchCursor(feat,"SHAPE@") as sCur:
for Row in sCur:
thisGeom = Row[0]
projGeom = thisGeom.projectAs(toSR)
TotalArea += projGeom.area
TotalArea += Row[0]
with arcpy.da.UpdateCursor(feat,"TotArea") as uCur:
for Row in uCur:
Row[0] = TotalArea
You will note the with statements.. these do not work for arcpy
cursors, only arcpy.da
cursors. When you declare a cursor in this way the disposal is automatic. You can of course use arcpy
cursors with this method:
def MySub (TotalArea1) :
desc = arcpy.Describe(feat)
shapeFieldName = desc.ShapeFieldName
TotalArea = 0.0
cursor = arcpy.SearchCursor(feat)
for row in cursor:
thisShape = row.getValue(shapeFieldName)
TotalArea += thisShape.area
del row
del cursor
cursor = arcpy.UpdateCursor(feat)
for row in cursor:
row.setValue("TotArea", TotalArea)
cursor.updateRow(row)
del row
del cursor
If you have a question about summary statistics please post that as a separate question.