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.

  • Remember that arcpy does not handle memory issues very well. If you have big tasks (complex/many features) you might end up with the message: "There is not enough memory." – ragnvald Oct 2 '12 at 11:08

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".

| improve this answer | |
  • Should have read @jburka's answer more carefully before posting! – djq May 5 '11 at 23:39

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...

| improve this answer | |

To batch buffer in ArcMap 10 you can use the built in tools. Just browse to Buffer in ArcToolbox (Analysis Tools < Proximity < Buffer), right-click the buffer tool and select batch.

| improve this answer | |

Sorry, I couldn't edit my comment properly; this is how I would go

arcpy.env.workspace = r'path\to\workspace'   
fcs = arcpy.ListFeatureClasses()  

    for fc in fcs:  
        arcpy.Buffer_analysis(fc, outBufferFeatureClass, "X meters")  
    print "Error buffering FeatureClasses."`   

I hope that helps. You will have to thread if you want to do it all at the same time.

| improve this answer | |
  • can you plaese Edit or comment back with arcpy.GetParameterAsText(0) for Input folder | arcpy.GetParameterAsText(1) for Buffer(Double) |arcpy.GetParameterAsText(2) for outputfolder ` arcpy.Buffer_analysis(fc, outputfolder+ fc", buffer) – GIS Data Butcher May 17 '15 at 6:14

Here is the ESRI Buffer/ArcPy link. Here you will find some general code examples.

| improve this answer | |
  • thanks but there is not example for buffering more than one feture class at once – BBG_GIS May 5 '11 at 18:54
  • @GISlove Why would you need to buffer more than one feature class at a time? Just curious. – Michael Todd May 5 '11 at 19:04
  • i want to learn for and while loop in python . this is the reason for batch buffering – BBG_GIS May 5 '11 at 20:44
  • @GISlove Ah, I thought you meant that you wanted to run all of the buffering jobs simultaneously. Batch buffering via python makes more sense. – Michael Todd May 5 '11 at 23:17
  • If you want to do them all at the same time, you'll have to put it into threads. – Hairy May 6 '11 at 10:40

The 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.

| improve this answer | |

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.