wcswatin
wcswatin is an open-source R package that prepares weather and climate time series for the Soil and Water Assessment Tool (SWAT). It supports data extraction, aggregation, interpolation, quality control, unit conversion, and the export of per-location model input files.
The package provides two complementary workflows:
- Raster and NetCDF processing: inspect NetCDF or GeoTIFF files, define study-area cells, extract gridded values, aggregate hourly or daily data, and write SWAT-style time-series files.
- Station data interpolation: read station files, fill gaps, reorganize daily observations, interpolate values with trend surfaces, and write point-based SWAT inputs.
Installation
Install the released version from CRAN:
install.packages("wcswatin")Or install the development version from GitHub:
# install.packages("remotes")
remotes::install_github("reginalexavier/wcswatin")Key capabilities
- Inspect variables, units, dates, extents, and dimensions in climate rasters.
- Process NetCDF and GeoTIFF data from sources such as ERA5-Land, GPM IMERG, and PERSIANN.
- Extract gridded values for watershed cells or reference points.
- Aggregate data cubes and hourly time series into daily products.
- Prepare SWAT weather files and interpolate station observations to target locations.
- Check completeness, summarize time series, convert units, and derive weather variables.
Documentation
The package website includes a getting-started guide, an ERA5-Land case study, a station interpolation workflow, and guidance for reproducing a similar case study.
Companion tool
cds-downloader is an optional, standalone Python CLI for creating reproducible daily or hourly ERA5-Land download requests through the CDS API. It can prepare NetCDF inputs for wcswatin, but neither tool requires the other.
Project and credits
wcswatin was developed by Réginal Exavier, Fernando Shinji Kawakubo, and Peter Zeilhofer. The project was developed with funding from the Critical Ecosystem Partnership Fund (CEPF) and is distributed under the GPL (>= 3) license.