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)
1 Answer 1
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– GIS Data Butcher2015年05月17日 08:50:49 +00:00Commented May 17, 2015 at 8:50
-
1What do you mean by "it is not added to display"?2015年05月17日 08:51:38 +00:00Commented May 17, 2015 at 8:51
-
Output should automatically added to current Arcmap window after finish this geoprocessing .GIS Data Butcher– GIS Data Butcher2015年05月17日 08:52:55 +00:00Commented May 17, 2015 at 8:52
-
1You 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.2015年05月17日 09:01:45 +00:00Commented May 17, 2015 at 9:01
-
1You can specify adding the output to the display using ModelBuilder, but scripts should not add data to the display by default.2015年05月17日 09:09:22 +00:00Commented May 17, 2015 at 9:09