NYGeog

Geography, GIS, Geospatial, NYC, etc.

Tuesday, October 26, 2010

Python code: Get count of features in feature class

Working on the Python command line in ArcGIS 10 I decided to try out some of the code examples:

>>> result = arcpy.GetCount_management("feature_class_name")
>>> print result.getOutput(0)
54 (or # of features in a feature class)

So this worked pretty well. However, and this seems to be a big however, but maybe not as it is likely beneficial at some point, but the number of features is resultant upon the selection of the features in the feature class. So if you have a certain number of features selected in that feature class then that will be the returned output not the total number of features. If nothing is selected then you will get the total number of features in that feature class. So perhaps the lesson is that what is in the "quotes" is not the feature class as we know it, but as the feature layer, as in what is defined in the map document.