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)

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) 
  • Thanks You Aaron..! it works but it is not added to display in Arcmap.. – GIS Data Butcher May 17 '15 at 8:50
  • 1
    What do you mean by "it is not added to display"? – Aaron May 17 '15 at 8:51
  • Output should automatically added to current Arcmap window after finish this geoprocessing . – GIS Data Butcher May 17 '15 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. – Aaron May 17 '15 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. – Aaron May 17 '15 at 9:09

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.