๐ Count Features in All Feature Classes Across Multiple GDBs (ArcPy)
In geospatial data management, it is often necessary to get a quick overview of the number of features across various layers and geodatabases. This ArcPy script automates the process of counting features in each feature class—both within and outside feature datasets—across multiple File Geodatabases (GDBs).
This solution is especially helpful for large-scale GIS projects where understanding the data volume is essential for quality control, reporting, and performance tuning.
๐ How the Script Works
๐ Directory Setup
The script begins by pointing to a parent folder that contains one or more .gdb files. It will recursively scan all subdirectories to find geodatabases.
๐ CSV Output
It outputs the results into a CSV file, listing each feature class’s name, the dataset it belongs to (if any), its shape type (Point, Polyline, Polygon, etc.), and the feature count.
๐ GDB Iteration
It checks each folder for .gdb extensions and sets the ArcPy workspace to the current geodatabase being processed.
๐งพ Feature Class & Dataset Traversal
The script counts features in:
-
Standalone feature classes
-
Feature classes inside feature datasets
✅ Summary in CSV
For each feature class found, it logs:
-
GDB Path
-
GDB Name
-
Dataset Name (or
None) -
Feature Class Name
-
Geometry Type
-
Count of features
๐ง Why Use This Script?
-
Quickly summarize large collections of geospatial data
-
Useful for data validation, inventory, and reporting
-
Automates a task that would otherwise require repetitive clicks in ArcGIS Pro or Catalog
-
Clean and exportable format (CSV) ready for Excel or reporting tools
๐งพ The Code
๐ก Key Points to Remember
-
The script automatically scans all
.gdbfiles in the given directory and subdirectories. -
It distinguishes between standalone and dataset-based feature classes.
-
Each feature class's geometry type and feature count are captured.
-
Results are written to a CSV file—easy to share or import into Excel.
✅ Use Case Scenarios
-
Preparing for data migration
-
Performing a QA/QC audit
-
Generating summary reports
-
Checking for unexpected empty layers
-
Monitoring data growth across projects