Subsets NHDPlusV2 features by location (POINT), area (POLYGON), or set of COMIDs. Multi realizations are supported allowing you to query for flowlines, catchments, or outlets.

get_nhdplus(
  AOI = NULL,
  comid = NULL,
  nwis = NULL,
  realization = "flowline",
  streamorder = NULL,
  t_srs = NULL
)

Arguments

AOI

sf (MULTI)POINT or (MULTI)POLYGON. An 'area of interest' can be provided as either a location (sf POINT) or area (sf POLYGON) in any Spatial Reference System.

comid

numeric or character. Search for NHD features by COMID(s)

nwis

numeric or character. Search for NHD features by collocated NWIS identifiers

realization

character. What realization to return. Default is flowline and options include: outlet, flowline, catchment, and all

streamorder

numeric or character. Only return NHD flowlines with a streamorder greater then or equal to this value for input value and higher. Only usable with AOI and flowline realizations.

t_srs

character (PROJ string or EPSG code) or numeric (EPSG code). A user specified - target -Spatial Reference System (SRS/CRS) for returned objects. Will default to the CRS of the input AOI if provided, and to 4326 for ID requests.

Value

sfc a single, or list, of simple feature objects

Details

The returned object(s) will have the same Spatial Reference System (SRS) as the input AOI. If a individual or set of IDs are used to query, then the default geoserver CRS of EPSG:4326 is preserved. In all cases, a user-defined SRS can be passed to t_srs which will override all previous SRS's (either input or default). All buffer and distance operations are handled internally using in EPSG:5070 Albers Equal Area projection

Examples

# \donttest{
 point <- sf::st_sfc(sf::st_point(c(-119.845, 34.4146)), crs = 4326)
 get_nhdplus(point)
#> Spherical geometry (s2) switched off
#> Spherical geometry (s2) switched on
#> Simple feature collection with 1 feature and 138 fields
#> Geometry type: LINESTRING
#> Dimension:     XY
#> Bounding box:  xmin: -119.8823 ymin: 34.40438 xmax: -119.8256 ymax: 34.4179
#> Geodetic CRS:  WGS 84
#> # A tibble: 1 × 139
#>   id             comid fdate               resolution gnis_id gnis_name lengthkm
#> * <chr>          <int> <dttm>              <chr>      <chr>   <chr>        <dbl>
#> 1 nhdflowline_… 9.48e8 2008-03-19 23:00:00 Medium     " "     " "           6.78
#> # … with 132 more variables: reachcode <chr>, 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 <int>, terminalpa <dbl>,
#> #   arbolatesu <int>, divergence <int>, startflag <int>, terminalfl <int>,
#> #   dnlevel <int>, uplevelpat <dbl>, uphydroseq <dbl>, dnlevelpat <dbl>,
#> #   dnminorhyd <int>, dndraincou <int>, dnhydroseq <dbl>, frommeas <int>, …
 get_nhdplus(point, realization = "catchment")
#> Spherical geometry (s2) switched off
#> Spherical geometry (s2) switched on
#> Simple feature collection with 1 feature and 7 fields
#> Geometry type: POLYGON
#> Dimension:     XY
#> Bounding box:  xmin: -119.8822 ymin: 34.40421 xmax: -119.8252 ymax: 34.41778
#> Geodetic CRS:  WGS 84
#> # A tibble: 1 × 8
#>   id                gridcode featureid sourcefc areasqkm shape_length shape_area
#> * <chr>                <int>     <int> <chr>       <dbl>        <dbl>      <dbl>
#> 1 catchmentsp.2609…  1482979 948060316 NHDFlow…     2.58        0.133   0.000253
#> # … with 1 more variable: geometry <POLYGON [°]>
 get_nhdplus(point, realization = "all")
#> Spherical geometry (s2) switched off
#> Spherical geometry (s2) switched on
#> Spherical geometry (s2) switched off
#> Spherical geometry (s2) switched on
#> $catchment
#> Simple feature collection with 1 feature and 7 fields
#> Geometry type: POLYGON
#> Dimension:     XY
#> Bounding box:  xmin: -119.8822 ymin: 34.40421 xmax: -119.8252 ymax: 34.41778
#> Geodetic CRS:  WGS 84
#> # A tibble: 1 × 8
#>   id                gridcode featureid sourcefc areasqkm shape_length shape_area
#> * <chr>                <int>     <int> <chr>       <dbl>        <dbl>      <dbl>
#> 1 catchmentsp.2609…  1482979 948060316 NHDFlow…     2.58        0.133   0.000253
#> # … with 1 more variable: geometry <POLYGON [°]>
#> 
#> $flowline
#> Simple feature collection with 1 feature and 138 fields
#> Geometry type: LINESTRING
#> Dimension:     XY
#> Bounding box:  xmin: -119.8823 ymin: 34.40438 xmax: -119.8256 ymax: 34.4179
#> Geodetic CRS:  WGS 84
#> # A tibble: 1 × 139
#>   id             comid fdate               resolution gnis_id gnis_name lengthkm
#> * <chr>          <int> <dttm>              <chr>      <chr>   <chr>        <dbl>
#> 1 nhdflowline_… 9.48e8 2008-03-19 23:00:00 Medium     " "     " "           6.78
#> # … with 132 more variables: reachcode <chr>, 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 <int>, terminalpa <dbl>,
#> #   arbolatesu <int>, divergence <int>, startflag <int>, terminalfl <int>,
#> #   dnlevel <int>, uplevelpat <dbl>, uphydroseq <dbl>, dnlevelpat <dbl>,
#> #   dnminorhyd <int>, dndraincou <int>, dnhydroseq <dbl>, frommeas <int>, …
#> 
#> $outlet
#> Simple feature collection with 1 feature and 138 fields
#> Geometry type: POINT
#> Dimension:     XY
#> Bounding box:  xmin: -119.8295 ymin: 34.4179 xmax: -119.8295 ymax: 34.4179
#> Geodetic CRS:  WGS 84
#> # A tibble: 1 × 139
#>   id             comid fdate               resolution gnis_id gnis_name lengthkm
#> * <chr>          <int> <dttm>              <chr>      <chr>   <chr>        <dbl>
#> 1 nhdflowline_… 9.48e8 2008-03-19 23:00:00 Medium     " "     " "           6.78
#> # … with 132 more variables: reachcode <chr>, 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 <int>, terminalpa <dbl>,
#> #   arbolatesu <int>, divergence <int>, startflag <int>, terminalfl <int>,
#> #   dnlevel <int>, uplevelpat <dbl>, uphydroseq <dbl>, dnlevelpat <dbl>,
#> #   dnminorhyd <int>, dndraincou <int>, dnhydroseq <dbl>, frommeas <int>, …
#> 
 get_nhdplus(comid = 101)
#> Spherical geometry (s2) switched off
#> Spherical geometry (s2) switched on
#> Simple feature collection with 1 feature and 138 fields
#> Geometry type: LINESTRING
#> Dimension:     XY
#> Bounding box:  xmin: -94.64845 ymin: 31.0838 xmax: -94.62997 ymax: 31.09915
#> Geodetic CRS:  WGS 84
#> # A tibble: 1 × 139
#>   id             comid fdate               resolution gnis_id gnis_name lengthkm
#> * <chr>          <int> <dttm>              <chr>      <chr>   <chr>        <dbl>
#> 1 nhdflowline_n…   101 2010-11-30 23:00:00 Medium     " "     " "           3.25
#> # … with 132 more variables: reachcode <chr>, 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 <int>,
#> #   dnlevel <int>, uplevelpat <dbl>, uphydroseq <dbl>, dnlevelpat <dbl>,
#> #   dnminorhyd <int>, dndraincou <int>, dnhydroseq <dbl>, frommeas <int>, …
 get_nhdplus(nwis  = c(11120000, 11120500))
#> Spherical geometry (s2) switched off
#> Spherical geometry (s2) switched on
#> Simple feature collection with 2 features and 138 fields
#> Geometry type: LINESTRING
#> Dimension:     XY
#> Bounding box:  xmin: -119.8296 ymin: 34.42014 xmax: -119.8057 ymax: 34.47472
#> Geodetic CRS:  WGS 84
#> # A tibble: 2 × 139
#>   id             comid fdate               resolution gnis_id gnis_name lengthkm
#> * <chr>          <int> <dttm>              <chr>      <chr>   <chr>        <dbl>
#> 1 nhdflowline_… 1.76e7 1999-11-18 23:00:00 Medium     269609  Atascade…     1.88
#> 2 nhdflowline_… 1.76e7 1999-11-18 23:00:00 Medium     273489  San Jose…     2.59
#> # … with 132 more variables: reachcode <chr>, 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 <int>,
#> #   dnlevel <int>, uplevelpat <dbl>, uphydroseq <dbl>, dnlevelpat <dbl>,
#> #   dnminorhyd <int>, dndraincou <int>, dnhydroseq <dbl>, frommeas <int>, …
 area <- sf::st_as_sfc(sf::st_bbox(c(xmin = -119.8851, xmax =-119.8361,
 ymax = 34.42439, ymin = 34.40473), crs = 4326))
 get_nhdplus(area)
#> Spherical geometry (s2) switched off
#> although coordinates are longitude/latitude, st_intersects assumes that they are planar
#> Spherical geometry (s2) switched on
#> Simple feature collection with 19 features and 138 fields
#> Geometry type: LINESTRING
#> Dimension:     XY
#> Bounding box:  xmin: -119.9143 ymin: 34.40438 xmax: -119.8256 ymax: 34.45475
#> Geodetic CRS:  WGS 84
#> # A tibble: 19 × 139
#>    id            comid fdate               resolution gnis_id gnis_name lengthkm
#>  * <chr>         <int> <dttm>              <chr>      <chr>   <chr>        <dbl>
#>  1 nhdflowline… 1.76e7 1999-11-18 23:00:00 Medium     " "     " "          0.725
#>  2 nhdflowline… 9.48e8 2008-03-19 23:00:00 Medium     " "     " "          6.78 
#>  3 nhdflowline… 9.48e8 2008-03-19 23:00:00 Medium     " "     " "          3.68 
#>  4 nhdflowline… 1.76e7 1999-11-18 23:00:00 Medium     " "     " "          0.221
#>  5 nhdflowline… 1.76e7 1999-11-18 23:00:00 Medium     " "     " "          0.369
#>  6 nhdflowline… 1.76e7 2008-03-19 23:00:00 Medium     "27404… "Tecolot…    0.867
#>  7 nhdflowline… 1.76e7 1999-11-18 23:00:00 Medium     " "     " "          0.833
#>  8 nhdflowline… 1.76e7 1999-11-18 23:00:00 Medium     " "     " "          0.241
#>  9 nhdflowline… 1.76e7 1999-11-18 23:00:00 Medium     " "     " "          0.91 
#> 10 nhdflowline… 1.76e7 1999-11-18 23:00:00 Medium     " "     " "          0.652
#> 11 nhdflowline… 1.76e7 1999-11-18 23:00:00 Medium     " "     " "          0.715
#> 12 nhdflowline… 1.76e7 1999-11-18 23:00:00 Medium     " "     " "          0.478
#> 13 nhdflowline… 1.76e7 1999-11-18 23:00:00 Medium     " "     " "          0.058
#> 14 nhdflowline… 1.76e7 1999-11-18 23:00:00 Medium     " "     " "          0.957
#> 15 nhdflowline… 1.76e7 2008-06-04 23:00:00 Medium     " "     " "          1.23 
#> 16 nhdflowline… 1.76e7 2008-06-04 23:00:00 Medium     " "     " "          1.05 
#> 17 nhdflowline… 1.76e7 2008-06-04 23:00:00 Medium     " "     " "          4.42 
#> 18 nhdflowline… 1.76e7 1999-11-18 23:00:00 Medium     " "     " "          0.672
#> 19 nhdflowline… 9.48e8 2010-11-30 23:00:00 Medium     " "     " "          0.218
#> # … with 132 more variables: reachcode <chr>, 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 <int>,
#> #   dnlevel <int>, uplevelpat <dbl>, uphydroseq <dbl>, dnlevelpat <dbl>,
#> #   dnminorhyd <dbl>, dndraincou <int>, dnhydroseq <dbl>, frommeas <dbl>, …
 get_nhdplus(area, realization = "flowline", streamorder = 3)
#> Spherical geometry (s2) switched off
#> although coordinates are longitude/latitude, st_intersects assumes that they are planar
#> Spherical geometry (s2) switched on
#> Simple feature collection with 8 features and 138 fields
#> Geometry type: LINESTRING
#> Dimension:     XY
#> Bounding box:  xmin: -119.8528 ymin: 34.41655 xmax: -119.8295 ymax: 34.42814
#> Geodetic CRS:  WGS 84
#> # A tibble: 8 × 139
#>   id             comid fdate               resolution gnis_id gnis_name lengthkm
#> * <chr>          <int> <dttm>              <chr>      <chr>   <chr>        <dbl>
#> 1 nhdflowline_… 1.76e7 1999-11-18 23:00:00 Medium     " "     " "          0.725
#> 2 nhdflowline_… 1.76e7 1999-11-18 23:00:00 Medium     " "     " "          0.221
#> 3 nhdflowline_… 1.76e7 1999-11-18 23:00:00 Medium     " "     " "          0.369
#> 4 nhdflowline_… 1.76e7 2008-03-19 23:00:00 Medium     "27404… "Tecolot…    0.867
#> 5 nhdflowline_… 1.76e7 1999-11-18 23:00:00 Medium     " "     " "          0.833
#> 6 nhdflowline_… 1.76e7 1999-11-18 23:00:00 Medium     " "     " "          0.241
#> 7 nhdflowline_… 1.76e7 1999-11-18 23:00:00 Medium     " "     " "          0.91 
#> 8 nhdflowline_… 1.76e7 1999-11-18 23:00:00 Medium     " "     " "          0.652
#> # … with 132 more variables: reachcode <chr>, 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 <int>,
#> #   dnlevel <int>, uplevelpat <dbl>, uphydroseq <dbl>, dnlevelpat <dbl>,
#> #   dnminorhyd <dbl>, dndraincou <int>, dnhydroseq <dbl>, frommeas <int>, …
 # }