Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

Hi friends: i have some feature class(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.

sincerely

share|improve this question
    
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
add comment

6 Answers 6

up vote 4 down vote accepted

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

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

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

share|improve this answer
add comment

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.

share|improve this answer
add comment

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.

share|improve this answer
add comment

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

share|improve this answer
    
thanks but there is not example for buffering more than one feture class at once –  wetland 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 –  wetland 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
show 1 more comment

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.