## example from Wikipedia
## 8835 is upstream of segments 8833 and 8811,
## but not segments 8832, 8821 or 9135
dwn <- c(8833, 8811, 8832, 8821, 9135)
is.upstream(8835, dwn)
## works with operator
8835 %up% dwn
## this will produce errors
if (FALSE) {
is.upstream("12h", 123)
is.upstream(12.4, 123)
}
## example from Verdin and Verdin, 1999, p. 10
b <- c(8883, 8881, 8879, 8877, 8875, 8873, 8871, 8859,
8857, 8855, 8853, 8851, 8839, 8837, 8835, 8833,
8831, 8819, 8817, 8815, 8813, 8811, 8886, 8887,
8888, 8889)
a <- 8885
a %down% b
## example from Vogt et al. (2007),
## pollution source at 464.
## Which subcatchments are
## affected? Mixed levels of subdivisions.
a <- 464
b <- c(465, 466, 467, 47, 48, 49,
463, 461, 41, 43, 45, 452,
454)
a %up% b
## same hydro codes return TRUE per default
112 %up% 112
112 %down% 112
Run the code above in your browser using DataLab