Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I don't know which one I need actually because I am relatively new to python. What my goal is to have a stand alone script to run multiple buffers based on user input. For example, I would like to ask the user how many buffers and then ask them what those buffers are.

How many buffers do you have? 3 What distances would you like to buffer? 50, 150, 250

I want to get all the input information before running the buffer tool. I'm guessing I need some type of loop.

share|improve this question

There is a built-in script tool that does exactly this: Multiple Ring Buffer

Screenshot of the Multiple Ring Buffer tool dialog

You can right-click it and go to edit to see the source Python script for its implementation.

If you want to roll your own (as a script tool), the key to the implementation is a multi-value parameter (of type double) for the distances, which at runtime is passed as a semicolon-delimited string argument, which you can then split up into a Python list object using str.split(), which you can then loop over using a for statement and create the buffers iteratively.

share|improve this answer

Take a look at the argparse module (which you can download separately if you're not using Python 2.7). Specifically the nargs keyword, which automatically puts your data into a list. For example:

import argparse

parser = argparse.ArgumentParser(description='Make some buffers')
parser.add_argument('buffers', metavar='distance', type=int, nargs='+',
                    help='Buffer distances')

args = parser.parse_args()
print "Number of buffers: %i" % len(args.buffers)
share|improve this answer
Note you can do similar with the optparse module, which is native to 2.6, but it's more complex. – om_henners Oct 10 '12 at 2:04

Your Answer


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.