Splits an 'sf' linestring object at the boundaries of runoff units (polygons).

split_river_with_grid(river, HS, riverID = "riverID", zoneID = "zoneID")

Arguments

river

An 'sf' linestring feature representing a river network.

HS

A 'HS' object, obtained with raster_to_HS.

riverID

A character string which specifies the name of the column in river containing unique river network identifiers. Defaults to "riverID".

zoneID

Name of the column in HS with unique IDs.

Value

Returns an 'sf' linestring object which has been split at the polygon (grid) boundaries with attributes (columns):

  • ID. Unique ID of the split river segments.

  • riverID. ID of the original river segment prior to splitting.

  • zoneID. ID of the runoff unit split river segment is contained in.

  • Other columns inherited from river.

Examples

if (FALSE) { library(raster) library(hydrostreamer) # load data data(river) data(basin) runoff <- brick(system.file("extdata", "runoff.tif", package = "hydrostreamer")) # create HS grid <- raster_to_HS(grid, aoi=basin) splitriver <- split_river_with_grid(river, grid, riverID="ID") }