Please help resolveThis is the following challenge: I have two feature classes, which have the same number of polygon features, that when overlaid form concentric "rings." I need to erase the inner circle from the outer circle for each feature, matching them by their record ID. So, if both feature classes 1 and 2 have records A, B, and C, I want to erase the polygon of Record A in FC2 from Record A in FC1, RecordB in FC2 from Record B in FC1, etc.
ArcGIS' Erase function will only take the entirety of the feature class and erase from them - I can't find a way to link up records by their feature ID.
I'm working with Arc10.1 with all licenses.
EDITLATEST EDITS: The following is a draft of I've replaced the useless code I'm having trouble editing. I'mfrom before with this revised snippet below, but now I need a novice Pythonbit of guidance -ista and my issue is I can't find where in developing/managing two SearchCursors athere that I am over-writing the same time? .output. It works! However the script leaves me with a single donut feature output.any takers to Can you help me get this rollingspot my error?
#Test script: select record from a VTR 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 = []
recordID3 = []
recordID4 = []
buffs = workspace+"buffer.gdb"
directorypath = buffs
#create new results_feature class
for dirpath, dirnames, buffs in arcpy.da.Walk(directorypath,
datatype="FeatureClass",
type="Polygon"):
for buff in buffs:
if buff.endswith(str("d4")):#buffbits=buff
# buffersd4.splitappend('_'buff)
#print buffersd4
#inputfc4 = print buff
buffbits4=buff.endswithsplit("d4"'_')
print buffbits4[2]
inputfc4bit=inputfc4 buffersd4.splitappend('_'buff)
inputfc3field = buff.endswith("d3")['APR16_ID']
APR16_ID inputfc3bit=inputfc3= [row[0] for row in arcpy.splitda.SearchCursor('_'workspace+"buffer.gdb\\"+buff,(field))]
print APR16_ID
for ifID4 inputfc4bit[2]==in inputfc3bit[2]APR16_ID:
ID4split #convert= inputfc4ID4.split('_')
and inputfc3 to feature layers
selectID4 = ID4split[1]
#MakeFeatureLayer_management(in_feat, out_layer, [where_clause}, {workspace},{field_infp})
#print selectID4
if buff.endswith(str("d3")):
in_feat4 = buffs+inputfc4 # buffersd4.append(buff)
#print buffersd4
out_feat4 = in_feat4+"_lyr" print buff
buffbits3=buff.split('_')
in_feat3 =print buffs+inputfc3buffbits3[2]
buffersd3.append(buff)
out_feat3 field = in_feat3+"_lyr"['APR16_ID']
APR16_ID = [row[0] for row in arcpy.MakeFeatureLayer_managementda.SearchCursor(in_feat4workspace+"buffer.gdb\\"+buff,out_feat4(field))]
print APR16_ID
arcpy for ID3 in APR16_ID:
ID3split = ID3.MakeFeatureLayer_managementsplit(in_feat3,out_feat3'_')
selectID3 #searchcursor= forID3split[1]
APR16ID in inputfc4 to match APR16Id in inputfc3
# print selectID3
print selectID4
print selectID3
if selectID4 == selectID3:
#SearchCursor(in_table, field_names,{where_clause},"","","")
print "yay they match!"
#make feature layer #where_clause=of """feature "APR16_ID"d4 =for """FCs +in
buffersd4:
for fc in buffersd4:
record_fc4 = arcpy in_feat=workspace+"buffer.SearchCursor(out_feat4,gdb\\"+fc
"APR16_ID", "","","")
out_layer4= fc+"_lyr"
record_fc3 = arcpy.SearchCursorMakeFeatureLayer_management(out_feat3, "APR16_ID","",""in_feat,""out_layer4)
print arcpy.GetMessages()
if record_fc3.APR16_ID#select ==record record_fc4.APR16_ID:
in fc_layer
#where_clause4=""" "APR16_ID" = """ + str(selectID4)
#select layer by attribute
where_clause4=""" "APR16_ID" = """ + "'"+ID4+"'"
#SelectLayerByAttribute_managementarcpy.SelectLayerByAttribute_management(in_layerout_layer4, {selection_type}"NEW_SELECTION", {where_clause}where_clause4)
print arcpy.GetMessages()
in_layer3 = out_feat3
#make feature layer of feature d3
for fc in buffersd3:
in_layer4 = out_feat4 in_feat=workspace+"buffer.gdb\\"+fc
out_layer3= fc+"_lyr"
arcpy.SelectLayerByAttribute_managementMakeFeatureLayer_management(in_layer3in_feat,out_layer3)
"NEW_SELECTION","","" print arcpy.GetMessages()
#select record in fc_layer
#where_clause3=""" "APR16_ID" = """ + str(selectID3)
where_clause3=""" "APR16_ID" = """ + "'"+ID3+"'"
arcpy.SelectLayerByAttrbiute_managementSelectLayerByAttribute_management(in_layer4out_layer3, "NEW_SELECTION","",""where_clause3)
print arcpy.GetMessages()
#erase funtion
#execute Erase function(erase d3 from d4)
erase_from out_feat = in_layer4"C:\\BOEM\\Donuts\\donuts_output.gdb\\"+"donut_d4_"+ID4
arcpy.Erase_analysis(out_layer4, out_layer3,out_feat,"")
erase_feat = in_layer3 print arcpy.GetMessages()
results_fcprint ="done workspace+"donuts_outputrolling through records in this feature class.gdb""
print "done going through the buffers in the arcpy.Erase_analysis(erase_from,fGDB"
erase_feat, results_fc,'')
#celebrate
`