I have some feature classes (7 feature classes) and I want to batch buffer in ArcGIS 10. I don't know how can I buffer at once. Please help me.
To buffer several features, you need to use some control structure. A technique I have found very useful is to store all of the shapefiles you are using in one folder, then loop through everything that is a shapefile. I do this using the
glob module, as follows:
# import modules import arcpy, glob # folder where shapefiles are stored folder = 'C:/myfiles/' # loop through all shapefiles for shapefile in glob.glob( folder + '*.shp' ): arcpy.Buffer_analysis( shapefile, "C:/output/" + shapefile[-8:-4] + "buffer.shp" "100 Feet", "FULL", "ROUND", "LIST", "Distance")
(See ArcGIS help here for more details)
I'm using an awkward way of naming the buffered file here (
shapefile[-8:-4]); a better way is to set the workspace using something like
arcpy.env.workspace = "C:/data".
As someone else already pointed out, you can use the Batch option by right-clicking the tool in Toolbox. Otherwise, it's hard to know how best to batch it without knowing more about the feature classes and their locations (are they all in the same workspace? are they the only feature classes in that workspace?) and the type of buffers you want to create (e.g. will they all have the same distance)
These things all go into, for instance, whether you're better off just typing in the name of a few feature classes into a list or if you should be using something like
arcpy.ListFeatureClasses to generate a list of feature classes to process.
Something as simple as:
import arcpy arcpy.env.workspace = r'path\to\workspace' featureClasses = ['fc1', 'fc2', 'fc3'] for featureClass in featureClasses: arcpy.Buffer_analysis(featureClass, "C:/output/" + featureClass + "Buffered" "100 Feet", "FULL", "ROUND", "LIST", "Distance")
would likely take care of it...
Sorry, I couldn't edit my comment properly; this is how I would go
arcpy.env.workspace = r'path\to\workspace' fcs = arcpy.ListFeatureClasses() try: for fc in fcs: arcpy.Buffer_analysis(fc, outBufferFeatureClass, "X meters") except: print "Error buffering FeatureClasses."`
I hope that helps. You will have to thread if you want to do it all at the same time.
Here is the ESRI Buffer/ArcPy link. Here you will find some general code examples.
Buffer tool does not work on more than one feature class at a time. If you want to buffer all the features in multiple feature classes, you will have to either merge the feature classes into one combined feature class and buffer that, or buffer each of the individual feature classes in a loop.