Skip to content

Instantly share code, notes, and snippets.

@cindygis
Last active August 29, 2015 14:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cindygis/8b77c2977a9434df9258 to your computer and use it in GitHub Desktop.
Save cindygis/8b77c2977a9434df9258 to your computer and use it in GitHub Desktop.
Gets the difference between two lists of SGs and applies a feature selection containing the difference
drak = [row[0] for row in arcpy.da.SearchCursor("DSG", "SG21Code")]
sga = [row[0] for row in arcpy.da.SearchCursor("SGA", "SGA.ID")]
lr_diff = lambda l, r: list(set(l).difference(r))
rest = lr_diff(sga, drak)
qry = """ SGA.ID IN (\'""" + "\', \'".join(rest) + "\')"
arcpy.management.SelectLayerByAttribute("SGA","NEW_SELECTION", qry)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment