Skip to contents

Overview

wcswatin (Weather & Climate SWAT Input) is an open-source R package for preparing weather and climate data from different sources for input in the Soil & Water Assessment Tool (SWAT).

The package provides two main workflows:

  • Raster/NetCDF Processing: Extract and process climate data from global gridded datasets (ERA5-Land, GPM IMERG, PERSIANN, etc.)
  • Station Data Interpolation: Upscale point measurements from weather stations using trend surface interpolation

Developed with funding from the Critical Ecosystem Partnership Fund (CEPF).

Key Features

  • Process NetCDF and GeoTIFF raster files from multiple climate data providers
  • Spatial and temporal data extraction for specific watersheds
  • Trend surface interpolation for station data upscaling
  • Gap-filling routines for station data
  • Direct output formatting for SWAT model input files
  • Optimized for large datasets with parallel processing support

Installation

Install the development version from GitHub:

# install.packages("devtools")
devtools::install_github("reginalexavier/wcswatin")

Quick Start

library(wcswatin)

# Process NetCDF climate data
climate_data <- input_raster(
  raster_file = "path/to/climate_data.nc",
  watershed = "path/to/watershed.shp",
  var_name = "precipitation"
)

# Interpolate station data
station_data <- ts_to_point(
  my_folder = "path/to/station_files",
  targeted_points_path = "path/to/centroids.shp",
  poly_degree = 2
)

Workflow Overview

Conceptual workflow of the wcswatin package

Conceptual workflow of the wcswatin package

Main Functions

Data Input & Loading

Raster/NetCDF Processing

Station Data Processing

SWAT-Specific Functions

Data Analysis & Utilities

Data Requirements

The package works with spatial data in WGS 84 geographic coordinate system (EPSG:4326), which is the standard format for most climate datasets.

Supported Data Sources

  • Climate Reanalysis: ERA5-Land, MERRA-2, NCEP
  • Satellite Precipitation: GPM IMERG, PERSIANN, CHIRPS
  • Station Data: Standard SWAT weather file format

Documentation

  • Vignettes: Detailed tutorials and workflows
  • Function Reference: ?function_name or visit package documentation
  • Examples: Run example(function_name) for usage examples

Getting Help

Citation

If you use wcswatin in your research, please cite:

@software{wcswatin2025,
  author = {Exavier, Reginal and Zeilhofer, Peter},
  title = {wcswatin: Weather & Climate SWAT Input},
  year = {2025},
  url = {https://github.com/reginalexavier/wcswatin}
}

License

GPL (>= 3)

Acknowledgments

This project is funded by the Critical Ecosystem Partnership Fund (CEPF).


Note: This package is under active development. Functions and features may change.