This repository provides a step-by-step workflow for regenerating a SWAT+ project from pre-processed inputs, performing essential diagnostics, and (optionally) proceeding to soft (crop yield) and hard (river discharge) calibration stages.
Webpage: https://mr-eini.github.io/Mini_setup_CREATE/
- Workflow at a glance
- Repository structure
- Prerequisites
- Quick start
- Step-by-step workflow
- Inputs and directory conventions
- Outputs
- Troubleshooting
- Acknowledgements / Funding
- Funding logos
- Citation
- License
The workflow is organized in numbered folders to support reproducible execution:
- Regenerate an uncalibrated SWAT+ setup from pre-processed GIS layers and tables (SWATbuildR + SWATprepR + SWATfarmR utilities).
- Run diagnostics to verify the model setup and key inputs/outputs.
- Soft calibration (crop yield) to improve crop growth realism.
- Hard calibration (river discharge) to match observed hydrographs.
- (Optional) NBS workflows for nature-based solution assessment.
1_Setup/— end-to-end setup regeneration workflow (from pre-processed inputs to a runnable SWAT+ setup).2_SWATdoctR/— model diagnostics utilities / routines (SWATdoctR-oriented).3_CropYield/softcal/— crop-yield soft calibration workflow.4_RiverDischarge/hardcal/— river-discharge hard calibration workflow.5_NBS/— (optional) nature-based solutions workflows/materials.assets/— figures and logos referenced by this README.
- A working SWAT+ executable (the model binary you want to run).
- write.exe (SWAT+ input writer; used to generate
TxtInOutfrom the SQLite database). - R (recommended: R 4.x) and (optionally) RStudio.
This repository relies on packages commonly used in OPTAIN-style SWAT+ workflows, including (non-exhaustive):
SWATprepR,SWATfarmR,SWATtunR,SWATrunR,SWATdoctR- Supporting packages such as
sf,dplyr,tidyverse,mapview, etc.
Example installation snippet (adapt and pin versions as needed):
install.packages("remotes")
install.packages(c("RNetCDF", "tidyverse", "mapview", "sf", "dplyr", "gstat"))
remotes::install_github("biopsichas/SWATtunR")
remotes::install_github("biopsichas/SWATprepR")
remotes::install_github("tkdweber/euptf2")
remotes::install_github("chrisschuerz/SWATfarmR")
remotes::install_github("chrisschuerz/SWATrunR@remove_legacy")
remotes::install_github("biopsichas/SWATdoctR")Note: Some workflows may expect specific SWATfarmR versions. See the
1_Setup/README.mdand the header comments in1_Setup/setup_workflow.R.
Clone the repository:
git clone https://github.com/MR-Eini/Mini_setup_CREATE.git
cd Mini_setup_CREATERun the setup regeneration workflow (typical):
cd 1_Setup
Rscript setup_workflow.RThen proceed to diagnostics and calibration steps using the numbered folders.
The 1_Setup/ folder contains an end-to-end workflow to regenerate a complete SWAT+ setup from pre-processed inputs to a runnable project (and to export a cleaned input-only setup for subsequent calibration/scenarios).
Key files:
1_Setup/setup_workflow.R— main workflow driver1_Setup/settings.R— project configuration (paths, years, SWATbuildR and SWATfarmR settings)1_Setup/functions.R— helper functions sourced bysetup_workflow.R
Important notes:
- Input data preparation is NOT part of this workflow. You must provide required pre-processed layers/tables externally.
- The workflow typically writes outputs into a results directory (commonly
Temp_) and may delete/recreate it. Review settings before running.
Recommended run modes:
- RStudio: open
1_Setup/, editsettings.R, thensource("setup_workflow.R"). - Command line:
cd 1_Setup && Rscript setup_workflow.R.
For full details, see 1_Setup/README.md.
The 2_SWATdoctR/ folder is intended for:
- Setup checks (file presence, configuration sanity)
- Output diagnostics (quick checks on simulation outputs)
- Workflow support routines (e.g., report generation)
Run the scripts in this folder after 1_Setup has produced a runnable setup (e.g., the TxtInOut folder and initial SWAT+ run).
The 3_CropYield/softcal/ folder is intended for soft calibration of crop growth/yields, typically by adjusting plant/crop parameters to better match observed yields or phenology.
Typical inputs:
- Observed yield (or crop performance) data for the calibration period
- The regenerated model setup (from
1_Setup, ideally the clean setup export) - Optional management / crop operation updates
Typical outputs:
- Parameter updates / calibration summaries
- Diagnostic plots/tables of yield fit
The 4_RiverDischarge/hardcal/ folder is intended for hard calibration against observed river discharge, typically involving parameter optimization and goodness-of-fit metrics.
Typical inputs:
- Gauge discharge time series
- A model setup that has passed basic diagnostics
- A defined calibration/validation period (plus warm-up)
Typical outputs:
- Calibrated parameter sets
- Fit metrics (e.g., NSE/KGE/RMSE) and hydrograph comparisons
The 5_NBS/ folder is intended for NBS-related workflows and scenario assessment materials. Contents may include scripts, templates, or analyses specific to nature-based solutions within the CREATE/OPTAIN-style context.
The setup workflow expects pre-processed GIS layers and tabular inputs. A typical structure referenced in 1_Setup looks like this (names are illustrative; configure paths in 1_Setup/settings.R):
1_Setup/
├── setup_workflow.R
├── settings.R
├── functions.R
├── Data/
│ ├── for_buildr/
│ │ ├── DEM1.tif
│ │ ├── soil1.tif
│ │ ├── Soil_SWAT_cod.csv
│ │ ├── usersoil_lrew.csv
│ │ ├── land1.shp (+ sidecars)
│ │ ├── river1.shp (+ sidecars)
│ │ └── basin1.shp (+ sidecars)
│ ├── for_prepr/
│ │ └── met_int.rds
│ └── for_farmr_input/
│ ├── crops1.shp (+ sidecars)
│ ├── mgt_crops.csv
│ └── mgt_generic.csv
└── Libraries/
├── buildr_script/
├── farmR_input/
├── files_to_overwrite_at_the_end/
├── write.exe
└── (SWAT+ executable)
Adapt the paths and names in 1_Setup/settings.R to match your local environment and dataset.
Depending on configuration, the workflow typically produces:
- A regenerated SWAT+ project (SQLite +
TxtInOut) - A backup of the generated SQLite database (zipped)
- Exported SWATfarmR input CSVs (management schedules)
- A clean input-only setup export (suitable for archiving, calibration, or scenario runs)
See 1_Setup/README.md for the expected output paths and export logic.
Common issues are documented in 1_Setup/README.md. Typical examples include:
- Multiple or missing
.sqlitedatabases in the results directory. write.exefailures (SQLite configuration / compatibility).- SWATfarmR version mismatches for management scheduling.
- Reservoir connectivity issues requiring consistency fixes.
This work was carried out within the CREATE project (Cross-REalm modelling and assessment of Aquatic ecosystem services – Towards a science-based design of nature-based solutions to tackle Eutrophication):
https://sisu.ut.ee/create-project/
Funding programme description: The project CREATE has received funding from the Estonian Research Council, Research Council of Finland, Latvian Council of Science, Research Council of Lithuania, National Centre of Research and Development in Poland, and the European Union’s Horizon Europe Programme under the 2023 Joint Transnational Call of the European Partnership Water4All (Grant Agreement No. 101060874).
If you use this workflow in a report/paper, you can cite the repository:
Mohammad Reza Eini, Department of Hydrology, Meteorology, and Water Management, Institute of Environmental Engineering, Warsaw University of Life Sciences, Warsaw, Poland SWAT+ Setup and Scenario Preparation Toolkit (OPTAIN-style workflow). GitHub repository. https://github.com/MR-Eini/Mini_setup_CREATE
Christoph, Schürz, Čerkasova Natalja, Farkas Csilla, Nemes Attila, Plunge Svajunas, Strauch Michael, Szabó Brigitta, and Piniewski Mikołaj. 2022. “SWAT+ modeling protocol for the assessment of water and nutrient retention measures in small agricultural catchments.” Zenodo. https://doi.org/10.5281/zenodo.7463395.
Piniewski, Mikołaj, Natalja Čerkasova, Svajunas Plunge, Michael Strauch, Christoph Schürz, Péter Braun, Enrico Antonio Chiaradia, Joana Eichenberger, Mohammad Reza Eini, Csilla Farkas, Marie Anne Eurie Forio, Peter Goethals, Piroska Kassai, Štěpán Marval, Diego G Panique-Casso, Lorenzo Sanguanini, Moritz Shore, Brigitta Szabó, Petr Slavík, Felix Witing. 2025. “Enhanced crop calibration for SWAT+: evaluating water, sediment and nutrient impacts across ten European catchments .” Environmental Modelling &Software 2025: 106794. https://doi.org/10.1016/j.envsoft.2025.106794.
Plunge, Svajunas, Christoph Schürz, Natalja Čerkasova, Michael Strauch, and Mikołaj Piniewski. 2024. “SWAT+ model setup verification tool: SWATdoctR.” Environmental Modelling & Software 171: 105878. https://doi.org/10.1016/j.envsoft.2023.105878.
Plunge, Svajunas, Brigitta Szabó, Michael Strauch, Natalja Čerkasova, Christoph Schürz, and Mikołaj Piniewski. 2024. “SWAT + input data preparation in a scripted workflow: SWATprepR.” Environmental Sciences Europe 36 (1): 53. https://doi.org/10.1186/s12302-024-00873-1.
Related community (OPTAIN): https://zenodo.org/communities/optain-h2020-project/
This repository currently indicates: MIT, GPL-3.0.




