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?

PolyGeo
65.5k29 gold badges115 silver badges350 bronze badges
asked Apr 22, 2016 at 17:22
1
  • 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. Commented Apr 22, 2016 at 17:42

1 Answer 1

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!

answered Apr 22, 2016 at 17:29
2
  • 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? Commented Apr 24, 2016 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 Commented Apr 25, 2016 at 10:29

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.