Skip to contents

Given input with fromnode and tonode attributes, will return the input with a toid attribute that is the result of joining tonode and fromnode attributes.

Usage

add_toids(x, return_dendritic = TRUE)

# S3 method for data.frame
add_toids(x, return_dendritic = TRUE)

# S3 method for hy
add_toids(x, return_dendritic = TRUE)

Arguments

x

data.frame network compatible with hydroloom_names.

return_dendritic

logical remove non dendritic paths if TRUE. Requires a "divergence" flag where 1 is main and 2 is secondary.

Value

hy object with toid attribute

Examples

g <- sf::read_sf(system.file("extdata/new_hope.gpkg", package = "hydroloom"))

x <- add_toids(hy(g))

y <- add_toids(g)

names(g)[1:4]
#> [1] "COMID"     "GNIS_ID"   "GNIS_NAME" "LENGTHKM" 

names(x)[1:4]
#> [1] "id"        "toid"      "GNIS_ID"   "GNIS_NAME"

names(y)[1:4]
#> [1] "COMID"     "toid"      "GNIS_ID"   "GNIS_NAME"