/UYRW_data

R scripts for acquiring and processing data needed for streamflow models of the Upper Yellowstone River Watershed

Primary LanguageR

about us

We are a team of mathematicians, statisticians, and ecologists, conducting a multi-year research project to develop an operational forecasting system for streamflow and water quality on the Upper Yellowstone River (UYR) and its tributaries. Our system will be based on SWAT+/gflow, a hybrid of the SWAT+ (Soil-Water-Assessment Tool) model for surface water dynamics, and gflow, physically-based groundwater flow module developed by Ryan Bailey to replace the current SWAT+ aquifer module.

R code

The UYRW_data repository is a staging area for R code that can be used to fetch data on the hydrology of UYR. This repository will be active during the early stages of our project (August-November 2020), as we assemble datasets and build documentation for the model. The following scripts download the data:

This script does some intermediate steps required to successfully load the data into QSWAT+3 and build a watershed model:

After running the above, the user can load the prepared raster and geometry data files into QSWAT+ (a plugin for QGIS), and construct a SWAT+ model from there. Alternatively, SWAT+ model construction can be done automatically (and much more quickly) via PyQGIS scripts, such as those provided in the SWAT+ Automatic Workflow (AW) by Celray James. An example that is customized for the UYRW_data project is linked below:

  • run_qswatplus (standalone) PyQGIS script for creating a SWAT+ model

We may open a new repository for this kind of python code, including parameter calibration scripts androutines for splitting large watersheds into smaller ones that can be calibrated sequentially. Check back for more scripts and figures as we add to this list in the coming weeks.

Our R data analysis workflow is structured around git and markdown. Our scripts (*.R) are documented as dynamic reports -- markdown files of the form *.knit.md. These document our code and methods in human-readable detail, with console output and figures incorporated automatically using rmarkdown using roxygen2. See Jennifer Bryan's Am Stat article and instructional pages for more on this.

funding

Our work is funded through a MITACS Accelerate International grant to Dean Koch, partnering the University of Alberta with R2CS LLC in Montana, and the Yellowstone Ecological Research Center. The project began on August 3, 2020.

gallery

R is a powerful data-retrieval, GIS, and visualization tool. These figures are generated by the scripts in our repo using the tmap package: