Skip to contents

Plots a river object

Usage

# S4 method for river,numeric
plot(x, y, type, ...)
# S4 method for numeric,river
plot(x, y, type, ...)
# S4 method for river,missing
plot(x, type, ...)

Arguments

x

A river object (or a numeric vector if y is a river).

y

A numeric vector to be displayed (or a river if x is a numeric vector). It is equivalent to theme in draw_subcatchments_OCN and draw_thematic_OCN. If y is specified, the river must have been aggregated. See details.

type

Optional argument. If type = "SC" or type = "subcatchments", draw_subcatchments_OCN is used (provided that the river object is aggregated); if type = "elev2D", draw_elev2D_OCN is used; if type = "contour", draw_contour_OCN is used (provided that the river object contains the CM field as produced by landscape_OCN or extract_river); alternatively, draw_thematic_OCN is 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