Python in ArcGIS Pro 2

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

1   Geoprocessing tools


One of major ways to extend the capability of ArcGIS Pro.

Can be invoked by Python.

2   Let’s try hydrology

  1. Download from GIS data.
  2. Add elevation.tif.
  3. Fill (Spatial Analyst)
  4. Flow Direction (Spatial Analyst)
  5. Flow Accumulation (Spatial Analyst)
  6. Raster Calculator (Spatial Analyst)

3   Geoprocessing history to Python code


4   Let’s look into auto-generated Python code

import arcpy
out_surface_raster ="elevation.tif", None);"C:\Users\hcho\AppData\Local\Temp\ArcGISProTemp24128\dd082615-93e5-456a-84c0-8c877b5bb9db\Default.gdb\Fill_tif1")

Some clean up

import arcpy

elev = "elevation.tif"
fill = r"C:\Users\hcho\AppData\Local\Temp\ArcGISProTemp24128\dd082615-93e5-456a-84c0-8c877b5bb9db\Default.gdb\Fill_tif1"

out_surface_raster =, None)

5   ArcPy

The core Python module for accessing ArcGIS Pro features from your Python code.

You have to use Esri’s Python environment.

C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\python.exe

Fill in Python

# to be able to pass command line arguments to Python
import sys

# ArcGIS Pro core module
import arcpy

# environment settings
# overwrite existing outputs
arcpy.env.overwriteOutput = True

# arguments from the user
elev = sys.argv[1]     # first argument
fill = sys.argv[2] # second argument

# run Fill
out_fill =, None)

# save the filled elevation raster

6   Homework: Flow accumulation script

Create a Python script that takes a flow direction file as input and a full path for flow accumulation output from the command line, and executes the Flow Accumulation (Spatial Analyst) tool. Upload this file only ( to D2L. Don’t upload a ZIP file. You’re warned!


  1. Filename -5
  2. It should take arguments from the command line. -30
  3. It requires any debugging? -5 per line added, removed, or edited; the command line penalty is separate.