get_sorted | R Documentation |
given a tree with an id and and toid in the first and second columns, returns a sorted and potentially split set of output.
Can also be used as a very fast implementation of upstream with tributaries navigation. The full network from each outlet is returned in sorted order.
get_sorted(x, split = FALSE, outlets = NULL)
x |
data.frame with an identifier and to identifier in the first and second columns. |
split |
logical if TRUE, the result will be split into independent networks identified by the id of their outlet. The outlet id of each independent network is added as a "terminalID" attribute. |
outlets |
same as id in x; if specified only the network emanating from these outlets will be considered and returned. |
data.frame containing a topologically sorted version of the requested network and optionally a terminal id.
source(system.file("extdata/new_hope_data.R", package = "nhdplusTools"))
fpath <- get_tocomid(
dplyr::select(new_hope_flowline, COMID, FromNode, ToNode, Divergence, FTYPE,
AreaSqKM, LENGTHKM, GNIS_ID)
)
head(fpath <- get_sorted(fpath, split = TRUE))
fpath['sort_order'] <- 1:nrow(fpath)
plot(fpath['sort_order'])
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.