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).
Solved! Go to Solution.
Replace "polygon" with "INPUT"
arcpy.Intersect_analysis([inputfeature,intersectfeature],outputfeature, "", "","INPUT")
How about hard-coding the tolerance value into the tool line of code to see if you can get past that error?
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.
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.
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"
Please Community Members help me debug this,,, i have to this by tonight cuz it's my lab work that I have to submit.
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")
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).
Could you share how both the input features look in ArcMap? Screenshots would help.
Yeah sure.