
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 sbar and north, respectively.
However, note that arguments d and xy must be specified by the user (because no rast object is plotted). See example.
Examples
set.seed(1)
OCN <- OCN_20
plot(OCN) # equivalent to draw_simple_OCN
OCN <- landscape_OCN(OCN)
plot(OCN) # equivalent to draw_contour_OCN
plot(OCN, type = "elev2D") # equivalent to draw_elev2D_OCN
OCN <- aggregate_OCN(OCN, thrA = 4)
plot(OCN) # equivalent to draw_thematic_OCN (with no theme specified)
plot(OCN, OCN$AG$A) # equivalent to draw_thematic_OCN (with theme specified)
plot(OCN, type = "contour") # equivalent to draw_contour_OCN
plot(OCN, type = "SC") # equivalent to draw_subcatchments_OCN (with no theme specified)
plot(OCN, OCN$AG$A, type = "SC") # equivalent to draw_subcatchments_OCN (with theme specified)
# now add scale bar and north arrow
library(terra)
# sbar() # this would throw an error
# north()# this would throw an error
sbar(d=1, xy=c(min(OCN$FD$X), min(OCN$FD$Y)-1)) # this works
north(d=1, xy=c(max(OCN$FD$X)+1, max(OCN$FD$Y))) # this works