ArcGIS Pro Python toolbox 2

Dr. Huidae Cho
Institute for Environmental and Spatial Analysis...University of North Georgia

1   How to define parameters

Use arcpy.Parameter and data types.

All parameters in arcpy.Parameter have a default value, but it doesn’t really make sense to omit the first five parameters*.

    name=,          #*Parameter name with no spaces (?)
    displayName=,   #*Parameter label for the user interface
    direction=      #*Input, Output
    datatype=,      #*Data type
    parameterType=, #*Required, Optional, Derived (always output with no user value; use SetParameterAsText to define its output)
    enabled=,       # False to make it unavailable (optional, None by default)
    category=,      # Parameter category (optional, None by default)
    symbology=,     # Path to a layer file for drawing the output (optional, None by default)
    multiValue=,    # True if the parameter has multiple values (optional, None by default)

Oops! That trailing comma after multiValue=? Don’t worry. Python can handle that for you.

2   Common data types

There are a lot of different data types, but for now, let’s focus on text, numbers, raster and feature layers.

Data typedatatype
Floating-point numberGPDouble
Input raster layerGPRasterLayer
Input feature layerGPFeatureLayer
Interactive input feature setGPFeatureRecordSetLayer
Output raster datasetDERasterDataset
Output feature classDEFeatureClass

3   Fill

    def getParameterInfo(self):
        elev = arcpy.Parameter(
        fill = arcpy.Parameter(

    def execute(self, parameters, messages):
        out_fill =

4   Flow direction

    def getParameterInfo(self):
        fill = arcpy.Parameter(
        fdir = arcpy.Parameter(

    def execute(self, parameters, messages):
        out_fdir =

5   Flow accumulation

    def getParameterInfo(self):
        fdir = arcpy.Parameter(
        facc = arcpy.Parameter(

    def execute(self, parameters, messages):
        out_facc =

6   Homework: Batch flow accumulation tool

Create a Python toolbox called FirstLastname_Hydrology.pyt with only one tool. This batch flow accumulation tool should take the following parameters:

  • elev: Input raster
  • fill: Output raster
  • fdir: Output raster
  • facc: Output raster

and executes the Fill, Flow Direction, and Flow Accumulation tools. The tool name should be BatchFlowAccumulation. Submit your FirstLastname_Hydrology.pyt only.