SWATprepR
The goal of SWATprepR
is to help with the SWAT+ model input data preparation. A detailed overview is presented in the article by Plunge, Szabó, et al. (2024). Most functions were developed for the implementation of modeling tasks in the OPTAIN project. These tools are intended to fill the gaps in the SWAT+ workflow alongside the main tools developed by Christoph Schuerz. Therefore, we highly recommend trying and using these tools:
- SWATbuildR1 - R tool for building SWAT+ setups.
- SWATfarmR - R tool for preparing management schedules for the SWAT model.
- SWATdoctR - A collection of functions in R and routines for SWAT model diagnostics. The package is presented in the article by Plunge, Schürz, et al. (2024).
- SWATrunR - R tool for running SWAT models for different parameters and scenarios.
- SWATtunR - R tool for soft & hard calibration, validation of SWAT+ models.
- SWATmeasR - R tool for implementing Natural/Small Water Retention Measures (NSWRMs) in the SWAT+ models and running scenarios.
Detailed information about packages, workflow steps, input data, SWAT+ parameters, model calibration, validation, etc., can be found in the SWAT+ modeling protocol by Christoph et al. (2022).
Installation
You can install the development version of SWATprepR
from GitHub. Please be aware that to run the get_usersoil_table()
function, the euptf2
package has to be installed. More information about this package can be found in the article by Szabó, Weynants, and Weber (2020). Other functions might require specific packages as well. Please check the documentation of the functions for more information.
# If the package 'remotes' is not installed run first:
install.packages("remotes")
# The installation of `SWATprepR`.
remotes::install_github("biopsichas/SWATprepR")
Data
All the data required to run and test the package is installed with the package in the extdata folder. The exact location on your computer can be found by running the lines below. Please run these commands on your system to locate it.
library(SWATprepR)
#> The legacy packages maptools, rgdal, and rgeos, underpinning the sp package,
#> which was just loaded, will retire in October 2023.
#> Please refer to R-spatial evolution reports for details, especially
#> https://r-spatial.org/r/2023/05/15/evolution4.html.
#> It may be desirable to make the sf package available;
#> package maintainers should consider adding sf to Suggests:.
#> The sp package is now running under evolution status 2
#> (status 2 uses the sf package in place of rgdal)
temp_path <- system.file("extdata", package = "SWATprepR")
print(temp_path)
#> [1] "C:/Users/Svajunas/AppData/Local/Programs/R/R-4.3.1/library/SWATprepR/extdata"
Templates
To use the SWATprepR
package functions with your data, you should prepare your data to align with the templates provided in the extdata folder. These templates include:
- calibration_data.xlsx - template for loading calibration (water flow and water quality variables) data.
- weather_data.xlsx - template for loading weather variables.
- usersoils.csv - example of a soil parameters dataset.
- pnt_data.xlsx - template for a point source dataset.
- GIS/ - folder with GIS layers needed to run some functions.
Data prepared according to these templates can be directly loaded into R, allowing you to apply all the functions as described.