Skip to contents

This function fills missing variables by interpolating values from the closest stations that have data.

Usage

fill_with_closest(
  meteo_lst,
  par_fill = c("TMP_MAX", "TMP_MIN", "PCP", "RELHUM", "WNDSPD", "SLR")
)

Arguments

meteo_lst

A nested list with dataframes. Nested structure: meteo_lst -> data -> Station ID -> Parameter -> Dataframe (DATE, PARAMETER). Nested 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.

par_fill

(optional) A vector of variables to be filled. Default is par_fill = c("TMP_MAX", "TMP_MIN","PCP", "RELHUM", "WNDSPD", "SLR").

Value

A list of dataframes with filled data. Updated list is for meteo_lst$data.

Examples

if (FALSE) {
  # Load weather data from an Excel file
  temp_path <- system.file("extdata", "weather_data.xlsx", package = "SWATprepR")
  met_lst <- load_template(temp_path, 3035)
  
  # Fill for missing variables
  met_lst$data <- fill_with_closest(met_lst, c("TMP_MAX", "TMP_MIN"))
}