## Example: write a blank rvh file
## create some blank tables
sbs_data <- rvn_rvh_blankSBdf(nSubBasins = 1)
hru_data <- rvn_rvh_blankHRUdf(nHRUs = 3)
# write to rvh file
rvn_rvh_write(file.path(tempdir(), "Blank.rvh"),
SBtable = sbs_data,
HRUtable = hru_data,
description = "Example output - Blank Watershed Discretization File",
author = "Raven Development Team")
# Example: Read in an rvh, clean its contents and write back to new file
nith <- system.file("extdata","Nith.rvh",package = "RavenR")
rvh <- rvn_rvh_read(nith)
# remove HRUs covering less than 5% of the total area
rvh$HRUtable <- rvn_rvh_cleanhrus(rvh$HRUtable, rvh$SBtable, area_tol = 0.05)
# write the Subbasin and HRU tables to new file using rvn_rvh_write:
rvn_rvh_write(filename=file.path(tempdir(), "Nith_cleaned_write.rvh"),
SBtable = rvh$SBtable,
HRUtable = rvh$HRUtable)
# write to new file, while preserving all unedited information using rvn_rvh_overwrite:
rvn_rvh_overwrite(filename=file.path(tempdir(), "Nith_cleaned_overwrite.rvh"),
basefile=nith,
SBtable = rvh$SBtable,
HRUtable = rvh$HRUtable)
Run the code above in your browser using DataLab