2

I have 5 buffers to perform using 5 fields of a shapefile. I try to run it with the following code:

Buffers = ['JF1','JF2','JF3','FF','FB']
env.workspace = "C:\Mydirectory\Myfile.shp"
network = "C:\Mydirectory\Myfile.shp"
out = "C:\Myoutputdirectory\Myfinaldirectory"
for buff in Buffers:
    arcpy.Buffer_analysis(network, out, buff,)

But when I do it I receive the following error:

ExecuteError: Failed to execute. Parameters are not valid.
ERROR 000725: Output Feature Class: Dataset Myfinaldirectory.shp already exists.
Failed to execute (Buffer).

What is the problem?

  • 2
    Along with @Paul answer, make sure you turn the slashes around in the file paths and remove the extra comma after buff argument in the buffer statement. – artwork21 Apr 22 '16 at 17:42
3

You aren't specifying a name for your output shapefile. arcpy is treating out as a file and appending ".shp" for you. You want a unique name for each output so that it isn't overwritten each loop.

import os
Buffers = ['JF1','JF2','JF3','FF','FB']

# This is a workspace
env.workspace = r"C:\Mydirectory"
# This is present in the workspace
network = "Myfile.shp"

# This is a directory, not a file
out = r"C:\Myoutputdirectory\Myfinaldirectory"

for buff in Buffers:
    # results in .\JF1.shp, .\JF2.shp, etc.
    arcpy.Buffer_analysis(network, os.path.join(out, buff), buff)

Edit: Fixed pathing per @artwork21 comments. Thanks!

  • Thank you now I do not receive that error anymore. Nevertheless now the code still does not run, and provides me with the following error: arcpy.Buffer_analysis(network, os.path.join(out,buff), buff,) File "C:\Program Files (x86)\ArcGIS\Desktop10.3\ArcPy\arcpy\analysis.py", line 692, in Buffer raise e ExecuteError: ERROR 000210: Cannot create output C:\MydirectoryJF1 Failed to execute (Buffer). What may be the reason now? – Patapunfate Apr 24 '16 at 9:31
  • I solved the problem apparently I am not allowed to create folders outside the ArcGIS gdb folder. I simply modified my directory and now it works – Patapunfate Apr 25 '16 at 10:29

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.