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.

See also

draw_simple_OCN, draw_elev2D_OCN, draw_contour_OCN, draw_subcatchments_OCN, draw_thematic_OCN

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
# }
}