2

I am writing script to take shape files from a folder to Buffer it to given distance to Output folder with same name as input files. Here are block of codes.

# Name: Buffer_multiple file.py
# Usage : inFolder to outfolder Buffer analysis
# import system modules 
import arcpy
from arcpy import env
# Set environment settings
arcpy.env.workspace= arcpy.GetParameterAsText(0)
arcpy.env.overwriteOutput = True
newFC = arcpy.ListFeatureClasses()
# get buffer size 
buffer = arcpy.GetParameterAsText(1)
# get output feature class
outputFeatureClass = arcpy.GetParameterAsText(2)
for fc in newFC:
 arcpy.Buffer_analysis(fc, outputFeatureClass+fc, buffer) 

It shows succeeded with No Output shapefile.

Executing: Script C:\Users\user1\Desktop\Input 20 C:\Users\user1\Desktop\buffered Start Time: Sun May 17 12:39:12 2015 Running script Script... Completed script Script... Succeeded at Sun May 17 12:39:14 2015 (Elapsed Time: 2.00 seconds)

asked May 17, 2015 at 7:14

1 Answer 1

3

The output workspace and the FC name need to be properly concatenated. You can do this by using os.path.join().

# import system modules 
import arcpy, os
from arcpy import env
# Set environment settings
arcpy.env.workspace= arcpy.GetParameterAsText(0) # type = workspace
arcpy.env.overwriteOutput = True
fcs = arcpy.ListFeatureClasses()
# get buffer size 
buffer = arcpy.GetParameterAsText(1) # type = integer
# get output feature class
outputWorkspace = arcpy.GetParameterAsText(2) # type = workspace
for fc in fcs:
 outfc = os.path.join(outputWorkspace, fc)
 arcpy.Buffer_analysis(fc, outfc, buffer) 
answered May 17, 2015 at 8:41
6
  • Thanks You Aaron..! it works but it is not added to display in Arcmap.. Commented May 17, 2015 at 8:50
  • 1
    What do you mean by "it is not added to display"? Commented May 17, 2015 at 8:51
  • Output should automatically added to current Arcmap window after finish this geoprocessing . Commented May 17, 2015 at 8:52
  • 1
    You will need to use the arcpy.mapping module for that: resources.arcgis.com/en/help/main/10.2/index.html#//…. I would recommend opening a new question for that operation. Commented May 17, 2015 at 9:01
  • 1
    You can specify adding the output to the display using ModelBuilder, but scripts should not add data to the display by default. Commented May 17, 2015 at 9:09

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.