How to calculate the total number of rows of several feature classes?

2756
4
09-10-2015 01:25 PM
MaryamSanieian
New Contributor

Hello Everyone,

I am performing a merge of several feature classes and I want to make sure I am missing any rows. In order to that I get the count of rows in each feature class and the row count of the output feature class and compare them.

The Get Count_management tool accepts one feature class at the time. How can I select several feature classes and count the rows as a total?

I tried creating variables that = arcpy.get count_management(featureclass) and then add them but I get an error message. It says these counts are results and not integers. 

Tags (1)
0 Kudos
4 Replies
JoshuaBixby
MVP Esteemed Contributor

You are close.  The Get Count tool, like most geoprocessing tools, returns Result objects.  Assuming you don't get any errors, the following should work:

res = arcpy.GetCount_management(dataset)
int(res.getOutput(0))
DarrenWiens2
MVP Honored Contributor

Consult the help page for the tool. At the bottom of each tool reference page, there is a code example.

For Get Count, the example shows how to return the integer value:

result = int(arcpy.GetCount_management(lyrfile).getOutput(0))
JayantaPoddar
MVP Esteemed Contributor

If you just need to know the total no. of records, add all the features to TOC; Turn all layers on. Zoom to Full extent. Select all the features using

At the bottom, you could see the total no. of features selected among all features (Make sure that all the layers are selectable)



Think Location
0 Kudos
MahtabAlam1
Occasional Contributor

You can run this within a for loop as :

for fc in fcList:
     arcpy.GetCount_management(fc)

where fcList is a list of feature class. You can also use arcpy.ListFeatureClasses() to get a list from workspace.

Thanks,

Mahtab