AnsweredAssumed Answered

Iterate through polygons and perform Intersect

Question asked by on Jun 25, 2020
Latest reply on Jun 26, 2020 by mpiraesriaustralia-com-au-esridist

Hi, I'm hopping for some help as I work through the process of writing a piece of code to produce an output of polygon intersects. My shape file contains many polygons which I would like to determine if any of them intersect and if they do add that intersect results to a new shape file. The code I used is below. I'm getting and error which is shown in a pic below.


Ultimately I'd like to have a single output shape file containing all intersect results. If you know a more efficient way or know how to make what I have work I am all ears!

I have attached a sample of the polygons. Many thanks for your attention!


I'm limited to using ArcMap 10.7 and python 2.7


import arcpy
from arcpy import env
import os

##Set working directory and workspace
wk_dir = os.getcwd()
env.workspace = wk_dir

##Assign feature class and working fields
fc = wk_dir + '\\CBT_Composite.gdb\\example_polys'
fields = ['RecordID', 'SHAPE@']

##Assign output file path and name
out = wk_dir + '\\output.gdb\\A'
##print fc_path + fc
with arcpy.da.SearchCursor(fc, fields) as cursor:
    for row in cursor:
        record = '{0}'.format(row[0]).split('.')[0]
        polygon = row[1]
        for row2 in cursor:
            if row2 != row:
                arcpy.Intersect_arc(row2[1], polygon, out +record) 


  picture of code

pic of error