3

I have a series of script tools created and work well in ArcMap 10.2.2 just fine. These tools generate a series of buffer features from an input feature class. I have these as separate tools each tool with a different set of buffer distances.

I want to be able to make one tool where the input feature class is chosen, then the set of buffer distances chosen out of a list from the script tool UI.

Example below of what is needed

import arcpy
arcpy.env.workspace = "C:\Buffers.gdb"
InPut = arcpy.GetParameterAsText(0)

#"select buffer situation B or A (not optional must be A or B)"


# Situation A Buffer 1
arcpy.Buffer_analysis(InPut,"first_Buff","16 METERS","FULL","ROUND","ALL")
# Situation A Buffer 2 
arcpy.Buffer_analysis("first_Buff","second_Buff","5 METERS","FULL","ROUND","ALL")

# Situation B Buffer 1
arcpy.Buffer_analysis(InPut,"first_Buff","20 METERS","FULL","ROUND","ALL")
# Situation B Buffer 2 
arcpy.Buffer_analysis("first_Buff","second_Buff","10 METERS","FULL","ROUND","ALL")
  • I think that what you wish to achieve, can be done by "Multiple Ring Buffer" script tool in Analysis toolbox. It is a script so in case you need to do something little different it could be a good source for inspiration/modification... – makak Jan 15 '16 at 7:16
5

Something like this might work

import arcpy 
arcpy.env.workspace = "C:\\Buffers.gdb" 
InPut = arcpy.GetParameterAsText(0)
Situation = arcpy.GetParameterAsText(1)

if Situation == 'Situation A':
    arcpy.Buffer_analysis(InPut,"first_Buff","16 METERS","FULL","ROUND","ALL")
    arcpy.Buffer_analysis("first_Buff","second_Buff","5 METERS","FULL","ROUND","ALL")

if Situation == 'Situation B':
    arcpy.Buffer_analysis(InPut,"first_Buff","20 METERS","FULL","ROUND","ALL")
    arcpy.Buffer_analysis("first_Buff","second_Buff","10 METERS","FULL","ROUND","ALL")

You'd then create a tool in ArcToolbox with a second parameter for Situation - set this as Text and create a Filter to create a drop-down list of 'Situation A' and 'Situation B'.

1

There are two parts to this:

  1. Use a second parameter to enable a pick list of buffer distances to be presented. This means using arcpy.GetParameterAsText(1) in your script as well as configuring the value list using the Parameters tab of the tool's Properties.
  2. Using the variable value (set in 1.) within an if/else construct to specify which lines of code are run.

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.