Select to view content in your preferred language

Layer Feature Count Function

337
3
07-16-2025 12:00 PM
DerekLindner
Emerging Contributor

Hello readers & contributors,

I'm a part time non-advanced Pro user and have a layer feature count function inquiry.

I would like be able to have the feature account of a layer visible in a different location than the attribute table
even if the layer is off.
From the blog as I understand it the feature count can be visible 4 ways-
as a legend label, as a dynamic text label, as arcpy.getcount command
and in the attribute table. (I'm trying to avoid having million count layers on or loading it's attribute table)

Can I embed the feature count into the layer name alias?
Can I append the dynamic label code* or Legend label so it shows the feature count even when the layer is off?
Is there another way to see the layer count (such as in the layer properties).

I appreciate any advice but *I would need guidance with all code suggestions.

Thanks for reading,

Derek L.

0 Kudos
3 Replies
Robert_LeClair
Esri Esteemed Contributor

Two quick way to get a feature count outside of the methods you described already:

Run the Get Count (Data Management)—ArcGIS Pro | Documentation geoprocessing tool in batch mode

Or open the Python window on the Analysis tab and in the Geoprocessing group, click the dropdown for Python and choose Python Window.  In the Python window, copy/paste the following code into the bottom row of the Python window and hit enter to run:

db = r'<your path to the file geodatabase'

arcpy.env.workspace = db

for ds in arcpy.ListDatasets():
for fc in arcpy.ListFeatureClasses('','',ds):
fc_path = os.path.join(db, fc)
fc_count = arcpy.GetCount_management(fc_path)
print("{0} : {1} rows".format(fc, fc_count))

PythonWindow.jpg

0 Kudos
DerekLindner
Emerging Contributor

Hello Robert_LeClair. Thank you for your suggestion & sorry for the delay responding. I made an .aprx of the old .mxd and made a gdb of the two feature classes. I fear I'm doing something wrong with inserting my fc and gdb location in the syntax. I'm about to create an esri support tix if I need to sent them the 617MB the but I thought I would ask you to look over my code first. Is here an appropriate place to inquiry about it?

0 Kudos
Robert_LeClair
Esri Esteemed Contributor

Hi @DerekLindner - 617 MB is a large file to send Esri Support but I'm sure it's been done in the past.  I can look at your code certainly and test things on my side if you like.  Caveat though - my Python skills are a work in progress so I rely upon many sources....

0 Kudos