1、从面要素中根据字段获取指定的面
def getCQXM(cqxmPath,objectid,val):
with arcpy.da.SearchCursor(cqxmPath, ["SHAPE@"], "{} = {}".format(objectid, val)) as cursor:
row = next(cursor, None)
if row is not None:
geometry = row[0]
times = int(time.time())
arcpy.CreateFeatureclass_management("in_memory", "temp_polygon_" + str(times), "POLYGON")
insertCursor = arcpy.da.InsertCursor("in_memory/temp_polygon_"+str(times), ["SHAPE@"])
insertCursor.insertRow([geometry])
return "in_memory/temp_polygon_"+str(times)
2、获取到内存中存储的面要素和sde中’cqh’的点要素使用arcpy.Intersect_analysis()方法进行叠加操作
def IntersectAnalysis():
times = int(time.time())
intersect_output = "in_memory/temp_intersect_" + str(times)
polygonPath = getCQXM(cqxm,'OBJECTID','972')
arcpy.Intersect_analysis([cqh,polygonPath], intersect_output, "ALL")
sfdf_false = '0'
sfdf_true = '1'
sfqy_false = '0'
sfqy_true = '1'
count_map = {'sfdf_false_count':0,'sfdf_true_count':0,'sfqy_false_count':0,'sfqy_true_count':0}
fields = ['OBJECTID','XMID','NHXM','SFDF','SFQY','COLOR','SJWZ','YDMJ','FZWBCCSDJ','BCHCSDJ','ZYZHXM','BCCSDJ','QYMC','QYBCCSDJ','CSBCZJHJ','XMMC','FWXZ']
with arcpy.da.SearchCursor(intersect_output, fields) as cursor:
for row in cursor:
if str(row[3]) == sfdf_false:
count_map['sfdf_false_count'] = count_map['sfdf_false_count']+1
if str(row[3]) == sfdf_true:
count_map['sfdf_true_count'] = count_map['sfdf_true_count']+1
if str(row[4]) == sfqy_false:
count_map['sfqy_false_count'] = count_map['sfqy_false_count']+1
if str(row[4]) == sfqy_true:
count_map['sfqy_true_count'] = count_map['sfqy_true_count']+1