adthompson

Alternative to Clipping code not working

Discussion created by adthompson on Jan 23, 2014
Latest reply on Jan 23, 2014 by JScheirer-esristaff
Hi
I am trying to use the following code as an alternative to using arcpy.clip as we are finding the clip funtion very slow when using a large footprint polygon. The inFC layer is a polygon layer (very large number of polygons) and the clipFC is a single polygon.
The problem is that when I run it I get the following error:
Runtime error
Traceback (most recent call last):
  File "<string>", line 16, in <module>
AttributeError: 'int' object has no attribute 'disjoint'

I am a newbee at python and so am not sure why I am getting this error. I am assuming it is something to do with the clipGeom variable not being right?

import arcpy, os, time
arcpy.env.overwriteOutput = True
print time.asctime()
inFC = r'D:\KATRIN\Data\testAllPolys.shp'
clipFC = r'D:\KATRIN\Data\testFootprint1.shp'
outFC = r'D:\KATRIN\Output\cliptest.shp'
clipGeom = [row[0] for row in arcpy.da.SearchCursor(clipFC,'Shape@')][0]
fields = ['FID','Shape@','FishingEve','TripId','GenericOct','FishingMet','TrueStatAr','cluster','TargetSpec','effort','AreaHa','EperHa','AnnualEpH']
import os
arcpy.CreateFeatureclass_management(os.path.dirname(outFC),os.path.basename(outFC),template=inFC)
inCursor = arcpy.da.InsertCursor(outFC,fields)
with arcpy.da.SearchCursor(inFC,fields) as cursor:
    for row in cursor:
        row = list(row)
        shp = row[0]
        if not shp.disjoint(clipGeom):
            shp = shp.intersect(clipGeom,4)
            if shp.type == u'polygon':
                row[0] = shp
                inCursor.insertRow(row)
print time.asctime()


Many thanks

Outcomes