Quantcast
Channel: Forums - Python
Viewing all articles
Browse latest Browse all 2485

Problem with my program of finding missing Annotation!!!!

$
0
0
I have a program that searches two layers inside an mxd and compares one field on each layer. For Example, the two layers AADT and AADTAnnoLabel are to compare Flag field on AADT and TFLAG field on AADTAnnoLabel. By comparing these the program is supposed to find missing annotation. For Example, AADT Flag has 150H105 and AADTAnnoLabel TFLAG does not have this id then it would select the Flag record in the AADT layer. For some reason the program is highlighting many records that are not missing anything meaning both layers have equal data in both fields. MY program is below :

Code:

import arcpy, traceback

mxd = arcpy.mapping.MapDocument("CURRENT")
lstLayers = arcpy.mapping.ListLayers(mxd)

flayer = arcpy.mapping.ListLayers(mxd, "AADT")[0]
alayer = arcpy.mapping.ListLayers(mxd, "AADTAnnoLabel")[0]

FRows = arcpy.SearchCursor(flayer)
ARows = arcpy.SearchCursor(alayer)

ffields = arcpy.ListFields(flayer, "FLAG", "String")
afields = arcpy.ListFields(alayer, "TFLAG", "String")

FList = []
AList = []

for row in FRows:
    Fvalue = row.getValue("FLAG")
    FList.append(str(Fvalue))

for row in ARows:
    Avalue = row.getValue("TFLAG")
    AList.append(str(Avalue))

matched = set(FList) & set(AList)

for x in matched:
    exp = '"FLAG" = ' + "'" + x + "'"
    arcpy.SelectLayerByAttribute_management("AADT", "ADD_TO_SELECTION", exp)
    arcpy.SelectLayerByAttribute_management("AADT", "SWITCH_SELECTION")


Viewing all articles
Browse latest Browse all 2485

Trending Articles