Fill missing variables from the closest stations with available data
Source:R/helper.R
fill_with_closest.Rd
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)
. Nestedmeteo_lst -> stations -> Dataframe (ID, Name, Elevation, Source, geometry, Long, Lat)
.
meteo_lst can be created usingload_template
function using 'xlsx' template file or it could to be created withload_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")
.
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"))
}