I would like to count the number of feature classes in a geodatabase. Some of the classes are in feature datasets as well. I have tried get count management, but that returns the number of rows in each feature class in the GDB.
Answer
You can run this code to get it:
arcpy.env.workspace = NAME OF GDB HERE
# Get stand alone FCs
fccount = len(arcpy.ListFeatureClasses("",""))
# Get list of Feature Datasets and loop through them
fds = arcpy.ListDatasets("","")
for fd in fds:
oldws = arcpy.env.workspace
arcpy.env.workspace = oldws + "\\" + fd
fccount = fccount + len(arcpy.ListFeatureClasses("",""))
arcpy.env.workspace = oldws
print fccount
Hope this works for you.
No comments:
Post a Comment