Quantcast
Channel: Question and Answer » arcpy
Viewing all articles
Browse latest Browse all 767

Cannot get correct result for output [on hold]

$
0
0

The attached is my Code and explanation of what I need to do. I need to add more extra function for this and get my final output result. Here is the code and explanation.

Example: GDB has [A,B,C,D] – 4 FCs.

1st round:

input FC: A (Do not use A- It is same as input)

Output R1= should be erase A from B (showing as A-B)and called Product_By_AB (copy it in memory)

R2= should be A-C and called Product_By_AC (copy it in memory)

R3= should be A-D and called Product_By_AD (copy it in memory)

Then intersect R1,R2,R3 —-> result will be R4

Then Replace R4 with A (which is an input FC for erase tool) and Keep the Same Name as A in the same folder/GDB to be used as new input FC for another round.

2nd round:

input FC:B (Do not use B – It is same as input)

Output R1= should be B-A and called Product_By_BA (copy it in memory)

R2= should be B-C and called Product_By_BC (copy it in memory)

R3= should be B-D and called Product_By_BD (copy it in memory)

Then intersect R1,R2,R3 —-> result will be R4
Then Replace new R4 (from Intersect part) with B (which is an input FC for erase tool) and Keep the Same Name as B in the same folder/GDB to be used as new input FC for another round.

and so on.

For script refer to arcpy.Erase_analysis function and output.

here is my code:

import arcpy
arcpy.env.overwriteOutput = True
arcpy.env.workspace = r'C:input.gdb'

Match_FC = arcpy.ListFeatureClasses()

for fclass in Match_FC:
  for fc in Match_FC:
    if fc != fclass:
        fclass_lyr = arcpy.MakeFeatureLayer_management(fclass, "fclass_lyr")
        fc_lyr = arcpy.MakeFeatureLayer_management(fc, "fc_lyr")
        arcpy.SelectLayerByLocation_management(fclass_lyr, 'INTERSECT', fc_lyr)
        desc = arcpy.Describe("fclass_lyr")
        fcIntersect=[]
        if desc.FIDSet:
            output = 'in_memory'
            output2='{}'.format(fclass)

            arcpy.Erase_analysis(fclass, fc,output, '')
            fcIntersect.append[output2]
            arcpy.DeleteFeatures_management(fclass)
            arcpy.Intersect_analysis(fcIntersect,output2)

        else:
           arcpy.Delete_management(fclass_lyr)
        arcpy.Delete_management(fc_lyr)

    else:
        "Skipping FC-{}".format(fc)

During running tool

Output from tool

Empty output


Viewing all articles
Browse latest Browse all 767

Trending Articles