Given flowlines and an rpu_code, performs a network-safe subset such that the result can be used in downstream processing. Has been tested to work against the entire NHDPlusV2 domain and satisfies a number of edge cases.

subset_rpu(fline, rpu, run_make_standalone = TRUE, strict = FALSE)

Arguments

fline

sf data.frame NHD Flowlines with comid, pathlength, lengthkm, hydroseq, levelpathi, rpuid, and arbolatesu (dnhydroseq is required if tocomid is not provided).

rpu

character e.g. "01a"

run_make_standalone

logical default TRUE should the run_make_standalone function be run on result?

strict

logical if TRUE, paths that extend outside the RPU but have no tributaries in the upstream RPU will be included in the output.

Value

data.frame containing subset network

Examples


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

sample_flines <- sf::read_sf(sample_data, "NHDFlowline_Network")

subset_rpu(sample_flines, rpu = "07b")
#> Simple feature collection with 267 features and 136 fields
#> Geometry type: MULTILINESTRING
#> Dimension:     XYZM
#> Bounding box:  xmin: -89.58537 ymin: 42.95163 xmax: -89.19935 ymax: 43.30179
#> z_range:       zmin: 0 zmax: 0
#> m_range:       mmin: 0 mmax: 100
#> Geodetic CRS:  GRS 1980(IUGG, 1980)
#> # A tibble: 267 × 137
#>       COMID FDATE               RESOLUTION GNIS_ID  GNIS_NAME LENGTHKM REACHCODE
#>       <int> <dttm>              <chr>      <chr>    <chr>        <dbl> <chr>    
#>  1 13296606 1999-10-15 00:00:00 Medium     "157707… "Yahara …    0.091 07090002…
#>  2 13297170 2009-05-01 00:00:00 Medium     "157707… "Yahara …    2.85  07090002…
#>  3 13297160 2009-05-01 00:00:00 Medium     "157707… "Yahara …    0.041 07090002…
#>  4 13293970 1999-10-29 00:00:00 Medium     "157707… "Yahara …    0.096 07090002…
#>  5 13293750 1999-10-29 00:00:00 Medium     "157707… "Yahara …    1.72  07090002…
#>  6 13296614 1999-10-15 00:00:00 Medium     " "      " "          4.59  07090002…
#>  7 13297104 1999-10-15 00:00:00 Medium     "156066… "Murphys…    4.53  07090002…
#>  8 13297106 1999-10-15 00:00:00 Medium     "156066… "Murphys…    2.70  07090002…
#>  9 13294002 1999-10-29 00:00:00 Medium     "157516… "Swan Cr…    0.111 07090002…
#> 10 13297098 1999-10-15 00:00:00 Medium     "157516… "Swan Cr…    1.44  07090002…
#> # … with 257 more rows, and 130 more variables: FLOWDIR <chr>,
#> #   WBAREACOMI <int>, FTYPE <chr>, FCODE <int>, Shape_Length <dbl>,
#> #   StreamLeve <int>, StreamOrde <int>, StreamCalc <int>, FromNode <dbl>,
#> #   ToNode <dbl>, Hydroseq <dbl>, LevelPathI <dbl>, Pathlength <dbl>,
#> #   TerminalPa <dbl>, ArbolateSu <dbl>, Divergence <int>, StartFlag <int>,
#> #   TerminalFl <dbl>, DnLevel <dbl>, UpLevelPat <dbl>, UpHydroseq <dbl>,
#> #   DnLevelPat <dbl>, DnMinorHyd <dbl>, DnDrainCou <int>, DnHydroseq <dbl>, …