Reads the output.hru file generated by SWAT, allowing users to filter
the data by variables, subbasin IDs, HRU IDs, and time steps (daily or
monthly).
Usage
output_hru(
file = "output.hru",
variable = NULL,
target_id = NULL,
time_step = "daily",
output_start_date
)Arguments
- file
Character. Absolute path to the
output.hrufile. Default is "output.hru".- variable
Character vector with the names of variables to read. Use
get_swat_vars("hru")to list all options. IfNULL, all variables are read.- target_id
Character vector of HRU IDs (HRUGIS). Default
NULLretrieves all HRUs.- time_step
Character. Time step of the simulation ("daily" or "monthly"). Default is "daily".
- output_start_date
Character. Date when SWAT output generation begins (first day after warm-up), in "yyyy-mm-dd" format.
Value
A data.frame with the selected variables for each HRU and time
step. Columns "LULC", "HRU", "GIS", "SUB", and "MON" are always included.
See also
Other Output readers:
get_swat_vars(),
output_rch(),
output_sub(),
read_pcp(),
read_tmp()
Examples
# Example with package data
tmpdir <- tempdir()
get_swat_example(tmpdir)
hru_file <- file.path(tmpdir, "TxtInOut", "output.hru")
hru_data <- output_hru(file = hru_file, variable = c("PRECIPmm", "ETmm", "WYLDmm"),
target_id = NULL, time_step = "daily",
output_start_date = "2011-01-01")
head(hru_data)
if (FALSE) { # \dontrun{
# Example with external SWAT project
hru_data <- output_hru(file = "C:/SWAT_Project/TxtInOut/output.hru",
variable = NULL, target_id = NULL,
time_step = "monthly",
output_start_date = "2000-01-01")
} # }