0

I am very new to Python.

I built a model in the ModelBuilder in a toolbox in ArcCatalog 10.3.1. I keep getting the following error about my buffer not being able to be executed and that my parameters are not valid. I set a field for a distance value for my buffer, my buffer, and a spatial join output as Model Parameters in my model builder before I exported the script to Python to run in Python IDLE:

Traceback (most recent call last): File "F:\Projects\Working\HurricanesSCRIPT.py", line 49, in arcpy.Buffer_analysis(Hurricanes_in_Counties, Hurricanes_Buffer, v15_Miles, "FULL", "ROUND", "NONE", "", "PLANAR") File "C:\Program Files (x86)\ArcGIS\Desktop10.3\ArcPy\arcpy\analysis.py", line 692, in Buffer raise e ExecuteError: Failed to execute. Parameters are not valid. ERROR 000725: Output Feature Class: Dataset F:\Projects\Working\ModelProject\ModelData.gdb\Hurricanes_Buffer already exists. Failed to execute (Buffer).

I have already put in arcpy.env.overwriteOutput = True just below import arcpy.

Here is the script for my arguments:

# Script arguments
v15_Miles = arcpy.GetParameterAsText(0)
if v15_Miles == '#' or not v15_Miles:
    v15_Miles = "15 Miles" #15 Miles

Hurricanes_Counties_SpaJoi = arcpy.GetParameterAsText(1)
if Hurricanes_Counties_SpaJoi == '#' or not Hurricanes_Counties_SpaJoi:
    Hurricanes_Counties_SpaJoi = "F:\\Projects\\Working\\ModelProject\\ModelData.gdb\\Hurricanes_Counties_SpaJoi" # provide a default value if unspecified

Hurricanes_Buffer = arcpy.GetParameterAsText(2)
if Hurricanes_Buffer == '#' or not Hurricanes_Buffer:
    Hurricanes_Buffer = "F:\\Projects\\Working\\ModelProject\\ModelData.gdb\\Hurricanes_Buffer" # provide a default value if unspecified

And here is the script for my buffer:

# Process: Buffer
arcpy.Buffer_analysis(Hurricanes_in_Counties, Hurricanes_Buffer, v15_Miles, "FULL", "ROUND", "NONE", "", "PLANAR")
  • 1
    Why did you delete your other question? That had valuable comments that will likely be rehashed on this question as people try to understand what you're doing. Please edit this question and include all the extra information you were asked for on your deleted question – Midavalo Sep 10 '16 at 20:48
  • 1
    What is Hurricanes_in_Counties? You have used this variable in your arcpy.Buffer_analysis(), but it is not defined in your arguments above. – Midavalo Sep 10 '16 at 20:50
  • 1
    As a new user it is unwise to delete questions because doing so feeds into the question limiting/banning algorithms that are run on the site. Doing it once will be OK but I advise strongly against doing it when you are far better to edit your questions. – PolyGeo Sep 10 '16 at 20:57
2

Add a check for whether the buffer feature class exists before you run your buffer. You can use this check to delete the existing buffer, or just print a message.

# Script arguments
v15_Miles = "15 Miles" #15 Miles
Hurricanes_Counties_SpaJoi = "F:\\Projects\\Working\\ModelProject\\ModelData.gdb\\Hurricanes_Counties_SpaJoi" # provide a default value if unspecified
Hurricanes_Buffer = "F:\\Projects\\Working\\ModelProject\\ModelData.gdb\\Hurricanes_Buffer" # provide a default value if unspecified

if arcpy.Exists(Hurricanes_Buffer):
    print "{} already exists!!".format(Hurricanes_Buffer)
    arcpy.Delete_management(Hurricanes_Buffer)

arcpy.Buffer_analysis(Hurricanes_Counties_SpaJoi, Hurricanes_Buffer, v15_Miles, "FULL", "ROUND", "NONE", "", "PLANAR")

I have used Hurricanes_Counties_SpaJoi in place of Hurricanes_in_Counties in the Buffer as Hurricanes_in_Counties wasn't defined in your arguments.


Additionally, check the caps are in the right place in your arcpy.env.overwriteOutput = True. This one (copied from your question above) is correct, however if the O from Output or the T from True are lower-case the overwriteOutput will not be set. Double-check that this is how you've used it in your script.

  • That worked. However, I got a new error but I'm going to see what I can do. – MapsandCats Sep 10 '16 at 21:12
  • @MapsandCats take note of my comment about the variable names (right after my code sample) - this will be why you're getting a name error when you try to run it as per your other question. – Midavalo Sep 11 '16 at 10:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.