Pi-Hellz

Batch intersecting

Discussion created by Pi-Hellz on Jan 7, 2013
Hi,

I have to do a batch intersecting with a condition on 50 shapefiles and I not really the way I should take to resolve my problem.


My problem is the input for my (second,third,...) intersect analysis is always the ouput of the last intersect analysis.

First intersect
arcpy.Intersect_analysis([fcGlobal,fclist[0]],outIntersect1)

What i'm trying to do :
arcpy.Intersect_analysis([outIntersect1,fclist[1]],outIntersect2)

arcpy.Intersect_analysis([outIntersect2,fclist[2]],outIntersect3)

arcpy.Intersect_analysis([outIntersect3,fclist[3]],outIntersect4)

until

arcpy.Intersect_analysis([outIntersect49,fclist[49]],outIntersect50)




import arcpy
from arcpy import env
env.overwriteOutput = True

env.workspace = "S:\Travail\Zone_Support_mutuel_test\Test_temp\ServiceAreaV2"

j = 1
outIntersectGlobal = "in_memory" + "\\" + "Global_Intersect1"
outputPolygons = "S:\Travail\Zone_Support_mutuel_test\Test_temp\ServiceAreaV2"
outIntersect = outputPolygons + "\\" + "Intersect"

# List all shapefile in folder
fcGlobal = arcpy.ListFeatureClasses("Global*","Polygons")
fclist = arcpy.ListFeatureClasses("C*","Polygons")
print fcGlobal[0]
print fclist[1]

# Intersecting the Global Network analysis layer with all the other Network fire station polygons
arcpy.Intersect_analysis([fcGlobal,fclist[0]],outIntersectGlobal)

codeblock = "def isSame(x, y):\n\n    fieldA = str(x)\n\n    fieldB = str(y)\n\n    if fieldA == fieldB:\n\n        return 1\n\n    else:\n\n        return 0\n"
isSameQuery = "isSame" = '1'

arcpy.AddField_management(outIntersectGlobal,"isSame","SHORT", "5", "", "", "", "NULLABLE", "NON_REQUIRED", "")
arcpy.CalculateField_management(outIntersectGlobal,"isSame","isSame( !Name!, !Name_1! )","Python_9.3",codeblock)
#arcpy.CopyFeatures_management(outIntersectGlobal, outputPolygons + "\\" + "Intersect")
arcpy.MakeFeatureLayer_management(outIntersectGlobal,"Intersect1",isSameQuery)

j = 1
outputName = "Intersect" + j

#######
#######
# I thought it will be something like that but it's not working 
#######
#######

for i in range(fclist)[j]:
    print i
    #arcpy.Intersect_analysis(["outputName","i"],



j+= 1



Thanks for your help

Outcomes