Compute "DistanceTo" Gradients
Compute "DistanceTo" Gradients
The DRC requires gradients between rivers, canals, and fields to be defined. These are provide through a set of 'DistanceTo' tables. These gradients are derrived from elevation data. Below is a description of the process for updating the 'DistanceTo' tables.
This assumes that a mosaiced digital elevation model (DEM) already exists for the DRC domain. A DEM for the Colorado River Basin in Utah is provided in the 'UCRAF_ControlTool' repo at: C:\...\UCRAF_ControlTool\UCRAF_Data\GIS\DEM (described here). The process for acquiring elevation tiles and creating a mosaiced DEM for another domain are described at the following links:
Whenever the "Water Right Distribution Network" or "Water Related Landuse" datasets are updated, it is necessary to regenerate the 'DistanceTo' tables used to compute downgradient runoff.
Updating the 'DistanceTo' gradient tables is accomplished using the UCRAF Toolbox in ArcGIS Pro through the following steps:
Note, it is possible to perform all the necessary functions outside of an ArcGIS environment, however, the process is more involved and requires running a compiled executable via the Command Prompt.
Locate the UCRAF Toolbox in the 'UCRAF_ControlTool' repository.
C:\...\UCRAF_ControlTool\ArcGIS\ArcToolbox
Open a new project in ArcGIS Pro and add the UCRAF Toolbox.
Go to Insert —>Toolbox —>Add Toolbox
Navigate to and select the UCRAF.atbx file and hit 'OK'.
Add the UCRAF Toolbox (UCRAF.atbx) to the project in ArcGIS Pro.
This step involves the creation of several rasters layers used to create the 'DistanceTo' Tables. These layers include Flow Direction and Flow Accumulation Rasters as well as rasterized flowlines and the water related landuse data. Select the 'PreProcess DistanceTo Files' Tool from the Terrain Processing Toolbox.
From the 'Terrain Processing' Toolbox, select the 'PreProcess DistanceTo File' tool highlighted in the Catalog Pane.
This step uses the mosaiced DEM created in the previous step (or provided for the UCRB in the repository), along with the boundary shapefile, a water related landuse shapefile, and a Flowlines shapefile. Anytime one of these files is updated, a new set of 'DistanceTo' tables needs to be created.
Double click on the '01 PreProcess DistanceTo Files' Tool. Set the working directory where the four output files will be created.
The following inputs are required:
DEM.tif
Duchesne_Boundary.shp
Net Flowlines.shp
State Wide Land Use 2023.shp
The following outputs are generated:
FDIR.tif
FAC.tif
STRMCANAL.tif
WRLU.tif
Set the working directory where the four output files will be created. These are intermediate files required to generate the 'DistanceTo' Tables. They do not need to be retained after that tables are created.
The other inputs, including the 'Net Flowlines.shp' downloaded in the previous step, are in provided in the UCRAF_ControlTool repository.
Specify a working directory and boundary extents along with the mosaic'd DEM, flowlines, and water related landuse shapefile. Then click 'Run' to generate the raster datasets in the working directory that was specified.
Click Run and wait for the processing to finish. This can take twelve or more minutes depending on computing resources.
Upon completion of the '01 PreProcess DistanceTo Files', four new files are created in the working directory that was secificed.
Once complete, four new raster files should now be saved in the working directory that was specified. These will be used in the next step to create the 'DistanceTo' tables.
Select the '02 Create DistanceTo Files Python' Tool to generate the four 'DistanceTo' Tables used by the DRC to calculate downgradient runoff.
In the Geoprocessing Pane, specify a working directory and load the DEM and other raster files created in the previous steps.
For the '02 Create DistanceTo Files Python' tool, specify the inpu
Set the working directory, where the DistanceTo tables will be written, to the directory containing the WRN in the 'UCRAF_ControlTool' repo under UCRAF_Data → GIS → DWRi Distribution Network → YYYYMMDD :
E.g., C:\...\UCRAF_ControlTool\UCRAF_Data\GIS\DWRi Distribution Network\20250515
The simulation name will be appended to as a prefix to the DistanceTo table file names. For UCRAF work, it's recommended to use "UCRB" for this field.
Then specify the location of 'DistanceToFieldsAndCanals.py' in the 'UCRAF_ControlTool' repo under DRC Files → DRC Source Code → Auxilarly_Tools → Compute_DistanceTo_Tables.
The python executable is available in the GitHub repository at: C:\...\UCRAF_ControlTool\DRC Files\DRC Source Code\Auxilary_Tools\Compute_DistanceTo_Tables.
For the 'Main Input File' field, keep 'DistanceToFieldAndCanals_MainInputFile.txt' as the default name.
Once the file paths/filenames are all specified, hit the 'Run' button. A terminal while open displaying the program execution. Wait for the tool to finish running. This will take several hours to complete.
Run the 'Create DistanceTo File' tool after specifying a working directory, simulation name, input files, along with the executable.
Once the executable finishes running, the four 'DistanceTo' text files needed to run the DRC are written to the working directory that was specified as shown below.
The six newly crated 'DistanceTo' files used by the DRC to compute the downgradient runoff from canal-to-fields, canals-to-rivers, fields-to-fields, and fields-to-canals are shown here in the working working directory.