Skip to contents

This function updates an SWAT+ SQLite database with weather data, including meteorological and weather generator data.

Usage

add_weather(db_path, meteo_lst, wgn_lst, fill_missing = TRUE)

Arguments

db_path

A character string representing the path to the SWAT+ SQLite database (e.g., "./output/project.sqlite").

meteo_lst

A nested list with dataframes. Nested structure: meteo_lst -> data -> Station ID -> Parameter -> Dataframe (DATE, PARAMETER), meteo_lst -> stations -> Dataframe (ID, Name, Elevation, Source, geometry, Long, Lat).

meteo_lst can be created using load_template function using 'xlsx' template file or it could to be created with load_swat_weather function loading information from SWAT+ model setup weather files.

wgn_lst

A list of two dataframes: wgn_st - weather generator station data, wgn_data - weather generator data (prepared by function prepare_wgn).

fill_missing

(optional) Boolean, TRUE - fill data for missing stations with data from closest stations with available data. FALSE - leave stations without data. Weather generator will be used to fill missing variables for a model. Default fill_missing = TRUE.

Value

Updated SWAT+ SQLite database with weather data.

Examples

if (FALSE) {
  # Getting meteorological data from template
  met_lst <- load_template(temp_path, 3035)
  
  # Calculating weather generator parameters
  wgn <- prepare_wgn(met_lst)
  
  # Writing weather input into the model database
  db_path <- "./output/test/project.sqlite"
  add_weather(db_path, met_lst, wgn)
}