AnsweredAssumed Answered

problem with clipping

Question asked by dschatt on Aug 16, 2016
Latest reply on Aug 17, 2016 by bharold-esristaff

hi all, I'm using PythonWin and also tried PyScripter to clip one polygon geodatabase feature class with each polygon in another polygon geodatabase feature class.  I've used this code successfully before with other data but suddenly, with this particular dataset, it's giving me problems.  

 

First I create a list (CatchmentIDLIst) from an item of unique values in the clip feature class, then loop through the polygons by selecting on each item in that list and setting that one as the present clip polygon.  I know the list is being created successfully because it prints out correctly in the interactive window after I create it.

 

But for some reason, the clip (Clip_analysis) operation isn't working properly.  Code below:

 

import arcpy
import os

MyWorkspace = "C:\stuff\PrecipitationFlooding/Norfolk"
arcpy.env.workspace = "C:\stuff\PrecipitationFlooding\Norfolk\Norfolk_Data.gdb"
arcpy.env.overwriteOutput = True

arcpy.MakeFeatureLayer_management("Catchments_Polygons_Dissolve", "Norfolk_Catchment_FLayer")

# Create list for all the Catchment ID values
CatchmentIDList = []

# Populate list with all the Catchment ID values
with arcpy.da.SearchCursor("Catchments_Polygons_Dissolve","OBJECTID") as CatchmentRowsCursor:
    for eachCatchmentRow in CatchmentRowsCursor:
        CatchmentIDList.append(eachCatchmentRow[0])

print str(CatchmentIDList).strip('[]')

#############################################################
#############################################################
######### Iterate through each catchment ####################
#############################################################
#############################################################

for EachCatchmentID in CatchmentIDList:
    print "Catchment ID = ", EachCatchmentID
    arcpy.SelectLayerByAttribute_management("Norfolk_Catchment_FLayer", "NEW_SELECTION","OBJECTID = " + str(EachCatchmentID))
   
    NorfolkLandUseByCatchment = "Norfolk_Landuse" + str(EachCatchmentID)
    arcpy.Clip_analysis("Norfolk_LandUse_SPS","Norfolk_Catchment_FLayer",NorfolkLandUseByCatchment)

 

The exact error is:

 

Traceback (most recent call last):
File "C:\stuff\PrecipitationFlooding\flooding.py", line 38, in <module>
arcpy.Clip_analysis("Norfolk_LandUse_SPS","Norfolk_Catchment_FLayer",NorfolkLandUseByCatchment)
File "C:\Program Files (x86)\ArcGIS\Desktop10.4\ArcPy\arcpy\analysis.py", line 56, in Clip
raise e
ExecuteError: ERROR 999999: Error executing function.
The table was not found.
The table was not found. [Norfolk_Landuse1]
The table was not found.
The table was not found. [Norfolk_Landuse1]
Invalid Topology [Topoengine error.]
Failed to execute (Clip).

 

I don't understand why it's trying to find a table "Norfolk_Landuse1".  It should be creating that feature class "Norfolk_Landuse1",  right?

 

Thanks much..

 

Dan

Outcomes