Select to view content in your preferred language

How to get number of features in shapefile from python?

6241
2
Jump to solution
01-30-2011 03:17 PM
JamesBattle
Emerging Contributor
Hi. I've been messing around with the python command window.

I can't figure out which property will tell me how many features are in my shapefile.

points = 'C:\ArcGIS_Tutorial\Vectormap\points.shp'

I looked at arcpy.describe but it's not what I am after.

If I can figure out how many features are in a shapefile, or how many datasets in a folder etc, it will be easy to create some for routines to process each one.

But until I find that property I am a bit stumped. Any tips on how to retrieve the answer in Python?

I know the answer is 10,000 from the attribute table - I created a 100 by 100 grid of regular points in a shapefile using Hawth's Tools. But I want to get that info programatically.

Thanks
Tags (2)
0 Kudos
1 Solution

Accepted Solutions
MatthewNordhagen
Frequent Contributor
Hi James - I believe what you are looking for is called Get Count.  It will return the number of records found in the attribute table of a feature class, table or raster.

http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//0017000000n7000000.htm

I don't have access to Python at the moment otherwise I would have attached a Python script for you but if you need any further help just let me know.

View solution in original post

0 Kudos
2 Replies
MatthewNordhagen
Frequent Contributor
Hi James - I believe what you are looking for is called Get Count.  It will return the number of records found in the attribute table of a feature class, table or raster.

http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//0017000000n7000000.htm

I don't have access to Python at the moment otherwise I would have attached a Python script for you but if you need any further help just let me know.
0 Kudos
JamesBattle
Emerging Contributor
Perfect answer. Thank you!

I was confused because it's a table tool, but I guess feature classes have tables so that's why it works here.

>>> arcpy.GetCount_management(points)
<Result '10000'>
0 Kudos