0

I'm trying to use the intersect tool, with one of my inputs being from a get parameter as text. As I don't have an advanced licence I have to iterate through the list to run the intersect on each item in the list.

However, there is something about the input into the intersect analysis it doesnt like. I get the error message:

Traceback (most recent call last): File "\DRBS-NAS01\ueec\GIS100円 MT testing\BufferTest\Scripts\Intersection batch.py", line 37, in arcpy.Intersect_analysis(Des4, DirectAndIndirect + "\test2", "ALL") File "c:\program files (x86)\arcgis\desktop10.7\arcpy\arcpy\analysis.py", line 334, in Intersect raise e ExecuteError: Failed to execute. Parameters are not valid. ERROR 000732: Input Features: Dataset SOBLayer #;'\DRBS-NAS01\ueec\GIS100円 MT testing\BufferTest\Data\Designations\Ancient_Woodland_England.shp' # does not exist or is not supported Failed to execute (Intersect).

 import arcpy
 import os
 
 ## Working folders
 WorkingDir = os.getcwd() ## To go up more directories: os.getcwd() 
 os.path.dirname(os.getcwd()); os.chdir(os.path.dirname(os.getcwd()))
 DesDir = WorkingDir + "\\Data\\Designations"
 OutputDir = WorkingDir + "\\Data\\Outputs"
 Interim = OutputDir + "\\Interim"
 DirectAndIndirect = OutputDir + "\\DirectAndIndirect"
 
 if not os.path.exists(DirectAndIndirect):
 os.makedirs(DirectAndIndirect)
 
 SiteOptions = arcpy.GetParameterAsText(0)
 SiteOptionsBuffers = arcpy.GetParameterAsText(1)
 
 DesList1 = arcpy.GetParameterAsText(2)
 DesList2 = DesList1.split(';')
 
 DesBufferList = arcpy.GetParameterAsText(3)
 
 arcpy.MakeFeatureLayer_management(SiteOptionsBuffers, "SOBLayer")
 
 query = '"IndImpBuff" = {}'.format(DesBufferList)
 arcpy.SelectLayerByAttribute_management("SOBLayer","NEW_SELECTION", query)
 
 Des4 = ["SOBLayer"]
 for Des1 in DesList2:
 Des2 = os.path.basename(Des1)
 Des4.append(Des1)
 arcpy.Intersect_analysis(Des4, DirectAndIndirect + "\\test2", "ALL")

Could someone suggest what the problem with the Intersect input is please?

PolyGeo
65.5k29 gold badges115 silver badges349 bronze badges
asked May 5, 2022 at 13:48
2
  • 1
    Try creating variables for the inputs of the intersect and use print statements to see if they're what you expect. Or, since this is being run as a script tool, use AddMessage. Commented May 5, 2022 at 14:35
  • 1
    You can use arcpy.Exists to check if the datasets exist. Commented May 5, 2022 at 16:00

1 Answer 1

0

Thanks for the comments. It's led me to a solution. The AddMessage was showing that in the DesList2 it was listing the dataset as:

u"'\DRBS-NAS01\ueec\GIS100円 MT testing\BufferTest\Data\Designations\Ancient_Woodland_England.shp'"

A bit of digging, and for reasons I dont understand, changing my loop as follows got it working:

for Des1 in DesList2:
 Des2 = os.path.basename(Des1)
 Des6 = Des1[1:-1].encode()
 Des4.append(Des6)
 arcpy.Intersect_analysis(Des4, DirectAndIndirect + "\\test2", "ALL")
answered May 6, 2022 at 8:57

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.