
Plot a river
plot.RdPlots a river object
Usage
# S4 method for class 'river,numeric'
plot(x, y, type, ...)
# S4 method for class 'numeric,river'
plot(x, y, type, ...)
# S4 method for class 'river,missing'
plot(x, type, ...)Arguments
- x
A
riverobject (or a numeric vector ifyis ariver).- y
A numeric vector to be displayed (or a river if
xis a numeric vector). It is equivalent tothemeindraw_subcatchments_OCNanddraw_thematic_OCN. Ifyis specified, the river must have been aggregated. See details.- type
Optional argument. If
type = "SC"ortype = "subcatchments",draw_subcatchments_OCNis used (provided that theriverobject is aggregated); iftype = "elev2D",draw_elev2D_OCNis used; iftype = "contour",draw_contour_OCNis used (provided that theriverobject contains theCMfield as produced bylandscape_OCNorextract_river); alternatively,draw_thematic_OCNis used.- ...
Arguments passed to the plotting functions
draw_simple_OCN,draw_contour_OCN,draw_thematic_OCN. See details.
Details
This is an interface to the plotting functions draw_simple_OCN, draw_elev2D_OCN, draw_contour_OCN, draw_subcatchments_OCN,
draw_thematic_OCN. If the river object does not have an elevation field (i.e., it has been generated
by create_OCN or create_general_contour_OCN, but landscape_OCN has not
been run), the plotting function used is draw_simple_OCN. If the elevation field is present, but the river
has not been aggregated (via aggregate_OCN or aggregate_river), the default plotting function used is
draw_contour_OCN. If the river has been aggregated, draw_subcatchments_OCN or draw_thematic_OCN are used depending on type.
Elevation maps can be produced with type = "elev2D", regardless of whether the river has been aggregated.
Adding scale bar and north arrow. Scale bar and north arrow can be added via terra's functions terra::sbar and terra::north, respectively.
However, note that arguments d and xy must be specified by the user (because no rast object is plotted). See example.
Examples
if (FALSE) { # interactive() && traudem::can_register_taudem()
fp <- system.file("extdata/wigger.tif", package="rivnet")
r <- extract_river(outlet=c(637478,237413),
DEM=fp)
plot(r) # equivalent to draw_contour_OCN
# \donttest{
r <- aggregate_river(r)
plot(r) # equivalent to draw_thematic_OCN
plot(r, type = "SC") # equivalent to draw_subcatchments_OCN
plot(r, type = "contour") # equivalent to draw_contour_OCN
# equivalent to draw_thematic_OCN with 'theme' specified
plot(r, r$AG$streamOrder, discreteLevels = TRUE)
plot(r$AG$streamOrder, r, discreteLevels = TRUE) # swapping arguments is allowed
# equivalent to draw_subcatchments_OCN with 'theme' specified
plot(r, r$SC$Y, type = "SC", addLegend = FALSE)
plot(r$SC$Y, r, type = "subcatchments", addLegend = FALSE) # swapping arguments is allowed
# plot elevation map
plot(r, type = "elev2D", drawRiver = TRUE)
# now add scale bar and north arrow
library(terra)
# sbar() # this would throw an error
# north()# this would throw an error
sbar(d=1000, xy=c(min(r$FD$X), min(r$FD$Y)-r$cellsize)) # this works
north(d=1000, xy=c(max(r$FD$X)+r$cellsize, max(r$FD$Y))) # this works
# }
}