Using python-propagator from python

You don’t have to start an ArcGIS session to use python-propagator. The analytical guts of the library are completely isolated from the ArcGIS interface portions. This allows users to directly use the analytical capabilities from a python script or an interactive python session.

There are two interfaces to the analytic capabilities:

  1. The toolbox API, which is easier to use and parallels the toolboxes.
  2. analysis_guide, which is more powerful but requires precise coding.

Common elements of examples

The following import statements are prerequisites for all of the code snippets below.

import numpy
import arcpy
import propagator
from propagator import utils

The toolbox API

(see install instructions)

For a full description of the API, see the reference guide

The propagator.toolbox interface provides a very high-level interface to python-propagator that very closely mimics the tooboxes. Just like how there are two forms in the ArcGIS toolbox, there are two analagous classes available in the propagator.toolbox API.

The propagator.toolbox.propagate() function allows the user to progagate water quality scores from monitoring locations to upstream subcatchments.

The propagator.toolbox.accumulate() function automatically accumulate upstream subcatchment attributes into stream features.

Common input parameters

The following are the parameters shared by both toolboxes. All parameters are required except where noted.

Analysis Workspace (workspace)

This is the folder or geodatabase that contains all of the input for the analysis.

Note

All of the input for the analysis (see below) must be in this workspace.

TBD

Code examples

Below is an example of using the propagator.toolbox.propagate() class to evaluate custom flood elevations.

# define the workspace as a geodatabase
workspace = r'F:\phobson\propagator\MB_Small.gdb'

with utils.WorkSpace(workspace):
    propagator.propagate(
        subcatchments='subbasins',
        id_col='Catch_ID',
        ds_col='DS_ID',
        monitoring_locations='wq_data',
        value_columns=['Dry_Metals', 'Wet_Metals', 'Wet_TSS'],
        output_path='propagated_metals'
    )

Below is an example of using the propagator.toolbox.accumulate() class to evaluate custom flood elevations.

# define the workspace as a geodatabase
workspace = r'F:\phobson\propagator\MB_Small.gdb'

# TBD