if (FALSE) { # interactive() && traudem::can_register_taudem()
fp <- system.file("extdata/wigger.tif", package="rivnet")
river <- extract_river(outlet=c(637478,237413), DEM=fp)
river <- aggregate_river(river)
# some random location of sampling sites, just to test the function
samplingSites <- c(2,15,30,78,97,117,132,106,138,153,156,159,
263,176,215,189,11,70,79,87,45,209,26,213)
# we use drainage area as an example variable to be shown
# 1) the function must be called after "plot(river)"
plot(river)
points_colorscale(river$AG$X[samplingSites], river$AG$Y[samplingSites],
river$AG$A[samplingSites])
# 2) change color palette
plot(river)
points_colorscale(river$AG$X[samplingSites], river$AG$Y[samplingSites],
river$AG$A[samplingSites],
bg.palette = hcl.colors(1000, "Inferno"))
# 3) impose a different range
plot(river)
points_colorscale(river$AG$X[samplingSites], river$AG$Y[samplingSites],
river$AG$A[samplingSites],
bg.range = c(0, 1e8))
# 4) show values outside the range as transparent
plot(river)
points_colorscale(river$AG$X[samplingSites], river$AG$Y[samplingSites],
river$AG$A[samplingSites],
bg.range = c(0, 1e8), force.range = FALSE)
# 5) show values both on inside and outside of the points (
# drainage area at the upstream vs. downstream end of the reach)
plot(river)
points_colorscale(river$AG$X[samplingSites], river$AG$Y[samplingSites],
data.frame(river$AG$A[samplingSites], 1.5*river$AG$A[samplingSites]),
bg.range = c(0, 1e8), col.range = c(0, 1e8),
lwd = 4)# increase contour line so it's more visible
# specify same range for both bg.range and col.range
# otherwise they will be shown on different scale
# 6) same as before, but show two different quantities:
# drainage area (inside) vs. elevation (outside)
# use different color palettes and add legend for the second color palette
plot(river)
points_colorscale(river$AG$X[samplingSites], river$AG$Y[samplingSites],
data.frame(river$AG$A[samplingSites], river$AG$Z[samplingSites]),
col.palette = terrain.colors(1000),
lwd = 4, add.col.legend = TRUE)
}
Run the code above in your browser using DataLab