split_flowlines: Split Flowlines

View source: R/split_flowline.R

split_flowlinesR Documentation

Split Flowlines

Description

A wrapper for split_lines that works on nhdplus attributes

Usage

split_flowlines(flines, max_length = NULL, events = NULL, para = 0, avoid = NA)

Arguments

flines

data.frame with COMID, toCOMID, LENGTHKM and LINESTRING sf column in "meters" projection

max_length

maximum segment length to return

events

data.frame containing events as generated by nhdplusTools::get_flowline_index() if an 'identifier' attribute is included, it will be passed through in the output table.

para

numeric how many threads to use in parallel computation

avoid

vector of ids to avoid

Value

All the flowlines with some split apart. COMIDs are returned as strings with a semantic part number appended. That is .1, .2, ... .10, .11, etc. are appended and must be treated as one would treat a semantic version. .1 is the most upstream and the sequence increases in the downstream direction.

See Also

The refactor_nhdplus function implements a complete workflow using 'split_flowlines()'.

Examples

source(system.file("extdata", "new_hope_data.R", package = "hyRefactor"))

new_hope_flowline <- 
  dplyr::right_join(dplyr::select(new_hope_flowline, COMID, REACHCODE, FromMeas, ToMeas),
                    suppressWarnings(nhdplusTools::prepare_nhdplus(
                      new_hope_flowline, 0, 0, 0, FALSE, warn = FALSE)),
                    by = "COMID")

split <- split_flowlines(suppressWarnings(sf::st_cast(sf::st_transform(
  new_hope_flowline, 5070), "LINESTRING")),
                         max_length = 2000, events = new_hope_events)

dblodgett-usgs/hyRefactor documentation built on Oct. 14, 2024, 12:59 p.m.