creates a node topology table from an edge topology

make_node_topology(x, add_div = NULL, add = TRUE)

Arguments

x

data.frame with an identifier and to identifier in the first and second columns.

add_div

data.frame containing id and toid diverted paths to add. Should have id and toid fields in the first and second columns. Names are not used.

add

logical if TRUE, a tocomid column will be added, otherwise a data.frame with two columns will be returned.

Value

data.frame containing id, fromnode, and tonode attributes or all attributes provided with id, fromnode and tonode in the first three columns.

Examples

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

x <- dplyr::select(get_tocomid(
  dplyr::select(new_hope_flowline, COMID, FromNode, ToNode, Divergence, FTYPE,
                AreaSqKM, LENGTHKM, GNIS_ID)
), -tonode, -fromnode)

head(y <- make_node_topology(x))
#> Warning: nhdplusTools make_node_topology is deprecated. Use hydroloom version.
#> Simple feature collection with 6 features and 9 fields
#> Geometry type: LINESTRING
#> Dimension:     XY
#> Bounding box:  xmin: 1505349 ymin: 1554873 xmax: 1508920 ymax: 1558708
#> Projected CRS: +proj=aea +lat_1=29.5 +lat_2=45.5 +lat_0=23 +lon_0=-96 +x_0=0 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs
#> # A tibble: 6 × 10
#>     comid tocomid fromnode tonode divergence ftype     areasqkm lengthkm gnis_id
#>     <int>   <dbl>    <int>  <int>      <int> <chr>        <dbl>    <dbl> <chr>  
#> 1 8898302 8896658        1      2          0 Artifici…    0.152    0.182 "98382…
#> 2 8896658 8896656        2      3          0 StreamRi…    1.19     1.37  "98382…
#> 3 8896656 8896624        3      5          0 StreamRi…    3.86     2.64  "98382…
#> 4 8896664 8896624        4      5          0 StreamRi…    1.38     1.64  " "    
#> 5 8896624 8896570        5      7          0 StreamRi…    1.34     1.17  "98382…
#> 6 8896572 8896570        6      7          0 StreamRi…    1.56     1.77  " "    
#> # ℹ 1 more variable: geom <LINESTRING [m]>

# just the divergences which have unique fromids in x but don't in new hope.
div <- get_tocomid(dplyr::select(new_hope_flowline, COMID, FromNode, ToNode),
                   return_dendritic = FALSE,
                   remove_coastal = FALSE)
div <- div[div$tocomid %in%
             new_hope_flowline$COMID[new_hope_flowline$Divergence == 2],]

y <- make_node_topology(x, div)
#> Warning: nhdplusTools make_node_topology is deprecated. Use hydroloom version.