arcpy 获取空间数据库中要素类名称和要素个数

时间:2024-05-21 22:39:02

import arcpy
from arcpy import env
import sys
import os

reload(sys)
sys.setdefaultencoding(‘utf8’)
path = “C:\Code\XYBASE.gdb”
print(path)
arcpy.env.workspace = path

for fds in arcpy.ListDatasets(’’,’’):
for fc in arcpy.ListFeatureClasses(’’, ‘’, fds):
nums=arcpy.GetCount_management(fc).getOutput(0)
print(“数据集[”+fds+"]下要素类["+fc+"]个数\t["+str(nums)+"]")

FeaClassNames=arcpy.ListFeatureClasses()
for FeaClassName in FeaClassNames:
nums=arcpy.GetCount_management(FeaClassName).getOutput(0)
print(“要素类[”+FeaClassName+"]个数\t["+str(nums)+"]")

效果如下:
arcpy 获取空间数据库中要素类名称和要素个数