I have 20-50 polygon layers in an mxd and I want to find out the aggregated amount of all features (global count). The shapefiles which are the source of those layers are stored in different folders. Just knowing the count would fulfill my requirements because it is just a quick check before I go on processing these files. Thus, I don't want to merge the files or count separately. I just need the simple amount.

Up to now, I can only think of a solution by coding a script in ArcPy, but I would prefer to find an easier way. I use ArcGIS 10.1.

  • 3
    So do you want to count features in different shapefiles, or in layers in an mxd? How do you want the result to be displayed? Just as a message? Do you want a separate count for every shp/layer or a global count of all features? And what version of ArcGIS do you use?
    – GISGe
    Jun 5, 2014 at 11:17
  • I have several polygon Shapefiles (around 20 to 50) and I want to find out the aggregated amount of all features (global count). The Shapefiles are in one mxd but saved in different folders. A message would fullfill my requirements because it is just a quick check before I go on processing these files. I use ArcGIS 10.1.
    – Gideon
    Jun 5, 2014 at 11:32
  • Maybe I should just code an ArcPy script but I hope there is an easier way.
    – Gideon
    Jun 5, 2014 at 11:33
  • 1
    The ArcPy script to do this, which could be put in a Python AddIn, just needs to iterate the layers from ListLayers and Get Count each one while keeping a running total to popup at the end. However, I cannot picture how such a grand total of features in a map can be useful.
    – PolyGeo
    Jun 5, 2014 at 12:26
  • 1
    If there aren't too many features total you can always just select everything, as a total selected count is given in the lower left of the window. But I'm guessing with 20-50 layers you might trip the 'you are about to select a large number of objects' warning and it could be a little slow.
    – Chris W
    Jun 5, 2014 at 19:05

1 Answer 1


You can copy/paste this code in the Python window in ArcMap to return the total number of features:

mxd = arcpy.mapping.MapDocument('current')
total_count = 0
for df in arcpy.mapping.ListDataFrames(mxd):
    for lyr in arcpy.mapping.ListLayers(df):
        if lyr.supports("dataSource"):
            result = arcpy.GetCount_management(lyr.dataSource)
            count = int(result.getOutput(0))
            total_count = total_count + count

print total_count

I haven't tested this with service layers and other specific data types present in the Table of Contents, that may not support GetCount.

  • Thank you so much! Works perfectly as long as the Shapefiles are not grouped.
    – Gideon
    Jun 5, 2014 at 13:13
  • 1
    I've edited the code, try this improved version
    – GISGe
    Jun 5, 2014 at 13:35
  • 2
    If you want, the entire thing can be done as a one liner, a la print sum(int(arcpy.GetCount_management(lyr.datasource)[0]) for lyr in df for df in arcpy.mapping.ListDataFrames(arcpy.mapping.MapDocument('current')) if lyr.supports("dataSource"))
    – Paul
    Jun 5, 2014 at 14:21
  • Good point, you don't risk to have indentation problems when copy/pasting this single line! Still I find it easier to read with the indentation and multiple lines.
    – GISGe
    Jun 6, 2014 at 8:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.