针对唯一值字段中的属性进行检查,将重复的属性值和重复次数检查出来。
# -*- coding:utf8 -*-
import arcpy
import os
from collections import Counter
workspace = r'E:\...\xxx.gdb'
arcpy.env.workspace = workspace
featureclasses = arcpy.ListFeatureClasses()
for fc in featureclasses:
print(fc)
gidAttList = [] # 宗地代码属性集合集合
with arcpy.da.SearchCursor(fc, ['YJJBNTTBBH', 'SHAPE@']) as cur:
for row in cur:
gidAttList.append(row[0])
b = dict(Counter(gidAttList))
# print ([key for key, value in b.items() if value > 1]) # 只展示重复元素
print ({key: value for key, value in b.items() if value > 1}) # 展现重复元素和重复次数