EDIT: Too big a question, I think - so, to refine it:
Please help me define (and therefore, research/learn how to use) the Pythonic concept for writing a script that can take one input variable, compare it against a list of other variables, and then holding onto both those variables, apply those IDs to an Arc function.
In this case, I need to take a FC, and with it's ID#, compare it to another FC with matching ID#. Then I need to read each record in the first FC, and then find and select the matching record in the matching FC. My script below does this but compares ALL the features in each FC to every other feature, in every other FC, in the fGDB.
I've left the initial question format below for context....
Thanks to the GIS StackExchange community helping with this challenge, I was able to develop the script below that almost accomplishes my goals.
However, I think I need a little guidance in the logic and theory behind the structure of this script. The script matches, within the fGDB, the featureID from one feature class to a matching featureID in another feature class. Something about the structure results in only creating rings for features in one feature class, while the goal is to create rings for each feature of each feature class in the fGDB.
I don't mean to request a script re-write, but I would appreciate someone helping point out the flaws in my logic structure for the script I've added here. It's a mess of for-loops and if-statements, that would be improved with defining functions, I just don't know how. Thanks very much!
#Test script: select record and erase it from another, matching selected record import os import sys import arcpy from arcpy import env import time #Set overwrote output arcpy.env.overwriteOutput = True print arcpy.env.overwriteOutput workspace = "C:\\BOEM\\pt_buff3\\" fileList =  buffersd4 =  buffersd3 =  buffs = workspace+"BUFFTEST.gdb" directorypath = buffs #Create new results_feature class for dirpath, dirnames, buffs in arcpy.da.Walk(directorypath, datatype="FeatureClass", type="Polygon"): #For all feature classes in the Buffer fGDB... for buff in buffs: buffbits=buff.split('_') if buffbits == str('d4'): buffersd4.append(buff) field = ['APR16_ID'] #For Feature Classes that end in 'd4', read through Features for the APR16_ID... with arcpy.da.SearchCursor(directorypath+"\\"+buff, ['APR16_ID']) as cursor: for ID4 in cursor: print ID4 #Create a list called APR16_ID4 of APR16IDs for the records in the d4 feature APR16_ID4 = [row for row in arcpy.da.SearchCursor(workspace+"BUFFTEST.gdb\\"+buff,['APR16_ID'])] elif buffbits == str('d3'): #For Feature Classes that end in 'd3', read through Features for the APR16_ID... buffersd3.append(buff) field = ['APR16_ID'] with arcpy.da.SearchCursor(directorypath+"\\"+buff, ['APR16_ID']) as cursor: for ID3 in cursor: print ID3 #Create a list called APR16_ID3 of APR16IDs for the records in the d3 feature APR16_ID3 = [row for row in arcpy.da.SearchCursor(workspace+"BUFFTEST.gdb\\"+buff,['APR16_ID'])] elif ID4 == ID3: print "early on, they match" else: print "no interesting files here" #New For-Loop: #If the feature ID matches, make feature layer and select feature by the ID4 and ID3 #from the feature class with a matching buffbits value. for buff in buffs: for ID4 in APR16_ID4: for ID3 in APR16_ID3: if ID4 == ID3: print "They really really match!" #make feature layer of feature d4 for FCs in buffersd4: for fc4 in buffersd4: in_feat=workspace+"BUFFTEST.gdb\\"+fc4 out_layer4= fc4+"_lyr" arcpy.MakeFeatureLayer_management(in_feat,out_layer4) print "Make Feature Layer for " + fc4 print "___" #print arcpy.GetMessages() #select record in fc_layer where_clause4=""" "APR16_ID" = """ + "'"+ID4+"'" arcpy.SelectLayerByAttribute_management(out_layer4,"NEW_SELECTION",where_clause4) #print arcpy.GetMessages() print "SelectLayer for "+ID4+" and "+out_layer4 print "______" #make feature layer of feature d3 for fc3 in buffersd3: in_feat=workspace+"BUFFTEST.gdb\\"+fc3 out_layer3= fc3+"_lyr" arcpy.MakeFeatureLayer_management(in_feat,out_layer3) #print arcpy.GetMessages() print "Make Feature Layer for " + fc3 print "___" #select record in fc_layer where_clause3=""" "APR16_ID" = """ + "'"+ID3+"'" arcpy.SelectLayerByAttribute_management(out_layer3,"NEW_SELECTION",where_clause3) #print arcpy.GetMessages() print "SelectLayer for " +ID3+" and " + out_layer3 print "______" #execute Erase function(erase d3 from d4) out_feat = "C:\\BOEM\\Donuts\\Donuts_output.gdb\\"+"don_d4_"+ID4 arcpy.Erase_analysis(out_layer4,out_layer3,out_feat,"") #print arcpy.GetMessages() print "Erase "+ out_layer3 +" from "+out_layer4+"to produce "+out_feat print "___" print "___" else: print "they don't match, next." print "done checking features for this feature class." print "done going through the buffers inthe fGDB"
(Hi, Moderators - Although this may be a StackOverflow-type question, I think it's still dealing with arcpy-specific syntax/script issues, so I left it in GIS StackExchange. If you disagree than please go ahead and migrate the conversation.)