python 获取要素图层个数

 1 #coding=utf-8
 2 
 3 import arcpy
 4 arcpy.env.workspace ="E:/城市矢量数据_原始/anhui合肥市/包河区"
 5 gd_f=arcpy.ListFiles("*国道.shp")
 6 if gd_f:  
 7     cnt=int(arcpy.GetCount_management(gd_f[0]).getOutput(0))
 8     print cnt
 9     print(gd_f[0])
10 else:
11     print('无国道')

结果

1 >>> ================================ RESTART ================================
2 >>> 
3 0
4 包河区_国道.shp
5 >>> 

posted on 2021-02-04 17:42  方圆几百里Idea  阅读(303)  评论(0编辑  收藏  举报

导航