Select to view content in your preferred language

Having an error while creating Intersect tool using python script

2326
11
Jump to solution
12-19-2021 08:39 AM
sabafatima
Emerging Contributor

Hello Community members!

I am trying to make an intersect tool using the python script but it is giving me errors after I try to run the created tool. Can any expert help me, please?

This is the Python script:

import arcpy
arcpy.env.workspace = "C:/Users/SABA FATIMA/Desktop/GIS App Labs/lab_pythontoolCreation"
inputfeature=arcpy.GetParameterAsText(0)
intersectfeature=arcpy.GetParameterAsText(1)
outputfeature=arcpy.GetParameterAsText(2)
cluster_tolerance =0.15
arcpy.Intersect_analysis([inputfeature,intersectfeature],outputfeature, cluster_tolerance, "polygon")

 

This is the error:

Failed script Script...

Traceback (most recent call last):
File "C:\Users\SABA FATIMA\Desktop\GIS App Labs\lab_pythontoolCreation\intersectPolygon.py", line 7, in <module>
arcpy.Intersect_analysis([inputfeature,intersectfeature],outputfeature, cluster_tolerance, "polygon")
File "c:\program files (x86)\arcgis\desktop10.7\arcpy\arcpy\analysis.py", line 334, in Intersect
raise e
ExecuteError: ERROR 000622: Failed to execute (Intersect). Parameters are not valid.
ERROR 000628: Cannot set input into parameter cluster_tolerance.


Failed to execute (Script).

0 Kudos
1 Solution

Accepted Solutions
JayantaPoddar
MVP Esteemed Contributor

Replace "polygon" with "INPUT"

 

arcpy.Intersect_analysis([inputfeature,intersectfeature],outputfeature, "", "","INPUT")

 



Think Location

View solution in original post

0 Kudos
11 Replies
MichaelVolz
Esteemed Contributor

How about hard-coding the tolerance value into the tool line of code to see if you can get past that error?

0 Kudos
sabafatima
Emerging Contributor

Already tried to do so...but still it gives the same error 

Error:

 

Failed script Script...

Traceback (most recent call last):
File "C:\Users\SABA FATIMA\Desktop\GIS App Labs\lab_pythontoolCreation\intersectPolygon.py", line 6, in <module>
arcpy.Intersect_analysis([inputfeature,intersectfeature],outputfeature, "0.15", "polygon")
File "c:\program files (x86)\arcgis\desktop10.7\arcpy\arcpy\analysis.py", line 334, in Intersect
raise e
ExecuteError: ERROR 000622: Failed to execute (Intersect). Parameters are not valid.
ERROR 000628: Cannot set input into parameter cluster_tolerance.

0 Kudos
MichaelVolz
Esteemed Contributor

Try creating a model and then export out to python script and compare to your script.

Add print statements for all inputs to ensure the correct information is being passed.

0 Kudos
sabafatima
Emerging Contributor

This same idea crossed my mind and I tried that but now, this error is showing up

Error:

Failed script Script...

Traceback (most recent call last):
File "C:\Users\SABA FATIMA\Desktop\GIS App Labs\lab_pythontoolCreation\intersectPolygon.py", line 9, in <module>
arcpy.Intersect_analysis("inputfeature;intersectfeature", outputfeature, "ALL", "", "INPUT")
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 inputfeature #;intersectfeature # does not exist or is not supported
Failed to execute (Intersect).


Failed to execute (Script).
Failed at Sun Dec 19 22:53:05 2021 (Elapsed Time: 0.19 seconds)

 

for code:

import arcpy
arcpy.env.workspace = "C:/Users/SABA FATIMA/Desktop/GIS App Labs/lab_pythontoolCreation"
inputfeature=arcpy.GetParameterAsText(0)
print "input completed"
intersectfeature=arcpy.GetParameterAsText(1)
print "intersect shp taken"
outputfeature=arcpy.GetParameterAsText(2)
print "output shp created"
arcpy.Intersect_analysis("inputfeature;intersectfeature", outputfeature, "ALL", "", "INPUT")
print "tool run successfully"

0 Kudos
sabafatima
Emerging Contributor

Please Community Members help me debug this,,, i have to this by tonight cuz it's my lab work that I have to submit. 

0 Kudos
JayantaPoddar
MVP Esteemed Contributor

A few points to check.

1. All the input feature classes are polygon feature classes (since you have mentioned your output_type as polygon).

2. What is the coordinate system of the input features? All the features should be in same coordinate system (A Projected Coordinate System).

3. Ensure there is no multipart feature. Run Multipart To Singlepart (Data Management) to see if any extra features are generated among the inut features. 

4. What happens if you don't define the Cluster Tolerance

arcpy.Intersect_analysis([inputfeature,intersectfeature],outputfeature, "", "","polygon")

 

 



Think Location
0 Kudos
sabafatima
Emerging Contributor

I performed all the checks you mentioned. Now, it's giving a new error.

Error:

Failed script Script...

Traceback (most recent call last):
File "C:\Users\SABA FATIMA\Desktop\GIS App Labs\lab_pythontoolCreation\intersectPolygon.py", line 6, in <module>
arcpy.Intersect_analysis([inputfeature,intersectfeature],outputfeature, "","", "polygon")
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 000800: The value is not a member of INPUT | LINE | POINT.
Failed to execute (Intersect).


Failed to execute (Script).

0 Kudos
JayantaPoddar
MVP Esteemed Contributor

Could you share how both the input features look in ArcMap? Screenshots would help.



Think Location
0 Kudos
sabafatima
Emerging Contributor

Yeah sure.

sabafatima_0-1639940032578.png

 

0 Kudos