Select to view content in your preferred language

How do I sum the areas of polygons in multiple shapefiles?

15054
14
02-17-2015 05:55 PM
StephenWheeler
Deactivated User

Hi All -- I have multiple geodatabases each with many shapefiles containing multiple polygons. I want to quickly and easily get the total area of polygons in each shapefile. I can't believe that ArcGIS is so cumbersome as to require me to add an Area field to each shapefile, calculate geometry, and then run statistics. Isn't there some simpler way to find out total area for each shape file?

 

Thanks so much for anyone's help! -- Steve Wheeler, U.C. Davis

0 Kudos
14 Replies
StephenWheeler
Deactivated User

Hi Jay - I've now got the FGDB and have imported the shapefiles...do I run Summary Statistics? This gives me an invalid pointer error message.

Thanks, Steve

Sent from my iPhone

0 Kudos
JayantaPoddar
MVP Alum

Make sure to define statistics field and statistics type as sum in Summary Statistics.



Think Location
0 Kudos
StephenWheeler
Deactivated User

Alas, this looks too complicated to use. There are quite a few steps for each file, and to find the answer I have to then open an output table, which I'm not sure how to do (opening it in catalog doesn't appear to give me the sum). I'm trying instead to open each attribute table in the new geodatabase and right-click on shape-area to get statistics. The main problem at the moment is getting the units right. I thought I had everything set to kilometres but the areas are coming out way too large.

I really appreciate your help.

Steve

Sent from my iPhone

0 Kudos
DarrenWiens2
MVP Alum

Are your expected areas either 1,000,000 (meters) or 10,764,000 (feet) times too large, by chance?

0 Kudos
XanderBakker
Esri Esteemed Contributor

Although very late, but you could do something like this with some Python code:

import arcpy
import os
workspace = r"C:\Path\To\Your\Folder"

sum_areas = 0
cnt = 0
walk = arcpy.da.Walk(workspace, topdown=True, datatype="FeatureClass", type="Polygon")
for dirpath, dirnames, filenames in walk:
    for filename in filenames:
        cnt += 1
        shp = os.path.join(dirpath, filename)
        area = sum([r[0] for r in arcpy.da.SearchCursor(shp, ("SHAPE@AREA")) if not r[0] is None])
        sum_areas += area
        print "shp: {0} has area {1}".format(shp, area)

print "{0} polygon featureclasses found".format(cnt)
if cnt > 0:
    print "total area: {0}".format(sum_areas)
    print "mean area per featureclass: {0}".format(round(sum_areas / float(cnt),2))