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.
Answer
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"
.
No comments:
Post a Comment