# Load example watershed data
data("example_watershed")
# Get bounding box to determine limits
b <- sf::st_bbox(example_watershed)
b
# Define a raster topology, using terra package,
# with the same CRS as the watershed. In this example cells have 100 m side.
# Coordinates in the 'sf' object are assumed to be cell centers
r <-terra::rast(xmin = 401380, ymin = 4671820, xmax = 402880, ymax = 4672620,
nrow = 8, ncol = 15, crs = "epsg:32631")
# Generate overland routing
or <- overland_routing(r, example_watershed)
# Plot elevation
plot(or["elevation"])
# Rank (decreasing elevation) for processing
plot(or["waterRank"])
# Plot outlet cells
plot(or["outlet"])
# Define 4-cell channel
example_watershed$channel <- FALSE
example_watershed$channel[c(6, 11, 12, 20)] <- TRUE
# Generate overland and channel routing
or_channel <- overland_routing(r, example_watershed)
# Plot outlet and distance to outlet
plot(or_channel["outlet"])
plot(or_channel["distance_to_outlet"])
Run the code above in your browser using DataLab