Queries the RVH object for subbasins or HRUs that are upstream of, downstream of, or the opposite of those conditions, for a given subbasin ID.
rvn_rvh_query(rvh = NULL, subbasinID = NULL, condition = "upstream_of")
rvh object as returned by rvn_rvh_read
subbasinID of basin of interest, as character or integer
condition applied to the query
rvhrvh object in same format, but queried to condition and all features (SBtable, HRUtable, SBnetwork) updated.
Based on the definition of subbasins by their outlets in Raven, it is assumed here that 'upstream' includes
the specified subbasin (i.e. everything upstream of subbasin X includes subbasin X as well), and 'downstream'
of subbasin X does not include subbasin X. This is different from the default behaviour of igraph
, which
includes the specified subbasin in either query.
Raven has capabilities for creating subbasin and HRU groups that meet certain criteria as well, consider reviewing the `:PopulateSubbasinGroup`, `:PopulateHRUGroup`, and other commands in Section A.3.2 of the Raven User's Manual.
rvn_rvh_write
to write contents of the generated (and usually modified HRU and SubBasin tables)
rvn_rvh_read
to read a Raven RVH file into R
# load example rvh file
nith <- system.file("extdata","Nith.rvh",package = "RavenR")
rvh <- rvn_rvh_read(nith)
# plot full watershed with igraph library
plot(rvh$SBnetwork)
# query all subbasins upstream of basin 39, plot
rvh_upstream_of_39 <- rvn_rvh_query(rvh, subbasinID=39, condition="upstream_of")
plot(rvh_upstream_of_39$SBnetwork)
# query of HRUs downstream of basin 39
rvn_rvh_query(rvh, subbasinID=39, condition="downstream_of")$SBtable
#> SBID Name Downstream_ID Profile ReachLength Gauged Area Elevation
#> 43 43 Sub43 -1 default_trap _AUTO 1 205 290
#> AvgLatit AvgLongit AvgSlope AvgAspect DomLU DomLUArea DomLUFrac DomVeg
#> 43 43.2571 -80.47377 1.273537 164.7571 AGRI1 120.9 58.98 CROP1
#> DomVegArea DomVegFrac TotalUpstreamArea
#> 43 180.8 88.2 1014.4