I am trying to write a script tool for my geospatial programming class and I am stuck (this is an online course and we get NO support from our instructor).
What I need to do is create buffers (different values) around three different features, these are set up as parameters that the user will define. I got this to work just fine.
Next, I need to perform a Union_analysis on those three buffer outputs, this is where I am getting stuck. I did this in a previous script, where I was using known feature classes, but I cannot figure out how to get this to recognize the outputs of the three "user selected" features.
Here is my script so far:
import arcpy arcpy.env.overwriteOutput = True buffered_area = "buffered_area" # Get the input parameters for the Buffer tool inPath = arcpy.GetParameterAsText(0) outPath = arcpy.GetParameterAsText(1) bufferDistance = arcpy.GetParameterAsText(2) inPath1 = arcpy.GetParameterAsText(3) outPath1 = arcpy.GetParameterAsText(4) bufferDistance1 = arcpy.GetParameterAsText(5) inPath2 = arcpy.GetParameterAsText(6) outPath2 = arcpy.GetParameterAsText(7) bufferDistance2 = arcpy.GetParameterAsText(8) # Run the Buffer tool buffer1 = arcpy.Buffer_analysis(inPath, outPath, bufferDistance) buffer2 = arcpy.Buffer_analysis(inPath1, outPath1, bufferDistance1) buffer3 = arcpy.Buffer_analysis(inPath2, outPath2, bufferDistance2) arcpy.Union_analysis("buffer1 #; buffer2 #; buffer3 #", buffered_area, "ALL", "", "GAPS")
And here is the error message I get:
Failed script Script1... Traceback (most recent call last): File "\\SNHU-LABS-UTIL2.snhu-labs.com\userprofiles$\william.herzig\Documents\programming\try.py", line 29, in <module> arcpy.Union_analysis("buffer1 #; buffer2 #; buffer3 #", buffered_area, "ALL", "", "GAPS") File "c:\program files (x86)\arcgis\desktop10.6\arcpy\arcpy\analysis.py", line 629, in Union raise e ExecuteError: Failed to execute. Parameters are not valid. ERROR 000732: Input Features: Dataset buffer1 #;buffer2 #;buffer3 # does not exist or is not supported WARNING 000725: Output Feature Class: Dataset \\SNHU-LABS-UTIL2.snhu-labs.com\userprofiles$\william.herzig\Documents\ArcGIS\Default.gdb\buffered_area already exists. Failed to execute (Union). Failed to execute (Script1).