# load example rvh file
nith <- system.file("extdata","Nith.rvh",package = "RavenR")
rvh <- rvn_rvh_read(nith)
# number of HRUs
nrow(rvh$HRUtable)
# total watershed area
sum(rvh$HRUtable$Area)
# sub-table of headwater basins (upstream area = subbasin area)
rvh$SBtable$SBID[rvh$SBtable$Area == rvh$SBtable$TotalUpstreamArea]
# sub-table of Urban HRUs
subset(rvh$HRUtable, LandUse == "URBAN")
# get total area upstream of subbasin containing outlet
upstr <- cumsum(rvh$SBtable$Area)
upstr[rvh$SBtable$Downstream_ID == -1]
# show upstream areas for each subbasin
rvh$SBtable[,c("SBID","TotalUpstreamArea")]
# plot network diagram using igraph library
igraph::plot.igraph(rvh$SBnetwork)
Run the code above in your browser using DataLab