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.

I want to write a loop that will cause the output to be multiple buffer shapefiles. For example I want a circle buffer of 50ft, 100ft, 150ft..... Can anyone help? I'm new to this and am trying to figure it out myself.

share|improve this question
1  
I know there is a tool that can do this (Multiple Ring Buffer) but I want to know how to write a loop. –  George Diamond Sep 21 '12 at 1:20
add comment

1 Answer

The ArcGIS Resource Center has the following sample script demonstrating how to do multiple ring buffers using Pyton

# Name: MultipleRingBuffer_Example2.py
# Description: Create multiple buffers for the input features
# Author: ESRI

# Import system modules
import arcpy
from arcpy import env

# Set environment settings
env.workspace = "C:/data/airport.gdb"

# Set local variables
inFeatures = "schools"
outFeatureClass = "c:/output/output.gdb/multibuffer1"
distances = [10,20,30]
bufferUnit = "meters"

# Execute MultipleRingBuffer
arcpy.MultipleRingBuffer_analysis(inFeatures, outFeatureClass, distances, bufferUnit, "", "ALL")

Here's how to do it if you insist on having a for loop

import arcpy

arcpy.env.workspace = "C:/data" 

distances =[50, 100, 150]
for distance in distances:
    outfile = "C:/output/majorrdsBuffered%s" % distance  
    arcpy.Buffer_analysis("roads", outfile, distance, "FULL", "ROUND", "LIST", "Distance")
share|improve this answer
2  
Would that for loop code not overwrite it's own outputs? It could be altered to say out_file = "C:/output/majorrdsBuffered" + str(distance) to put the buffersize in the filename. –  sgrieve Sep 24 '12 at 8:09
    
Thanks for noticing. Will update the answer. –  R.K. Sep 24 '12 at 9:32
    
arcpy.Buffer_analysis(clipoutfile, buffered + "_" + str(x) + ".shp", str(x)+" "+buff_unit) this is what I ended up doing as a call. –  George Diamond Sep 26 '12 at 0:09
    
Did it work? Good to know. The file names are your call in the end. –  R.K. Sep 26 '12 at 5:18
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.