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               resol…¹ gnis_id gnis_…² lengt…³ reach…⁴
#> * <chr>        <int> <dttm>              <chr>   <chr>   <chr>     <dbl> <chr>  
#> 1 nhdflowlin… 9.48e8 2008-03-19 23:00:00 Medium  " "     " "        6.78 180600…
#> # … with 131 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 <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>, tomeas <dbl>, …
 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_le…¹ shape…²
#> * <chr>                  <int>     <int> <chr>          <dbl>      <dbl>   <dbl>
#> 1 catchmentsp.2609886  1482979 948060316 NHDFlowline     2.58      0.133 2.53e-4
#> # … with 1 more variable: geometry <POLYGON [°]>, and abbreviated variable
#> #   names ¹​shape_length, ²​shape_area
 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_le…¹ shape…²
#> * <chr>                  <int>     <int> <chr>          <dbl>      <dbl>   <dbl>
#> 1 catchmentsp.2609886  1482979 948060316 NHDFlowline     2.58      0.133 2.53e-4
#> # … with 1 more variable: geometry <POLYGON [°]>, and abbreviated variable
#> #   names ¹​shape_length, ²​shape_area
#> 
#> $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               resol…¹ gnis_id gnis_…² lengt…³ reach…⁴
#> * <chr>        <int> <dttm>              <chr>   <chr>   <chr>     <dbl> <chr>  
#> 1 nhdflowlin… 9.48e8 2008-03-19 23:00:00 Medium  " "     " "        6.78 180600…
#> # … with 131 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 <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>, tomeas <dbl>, …
#> 
#> $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               resol…¹ gnis_id gnis_…² lengt…³ reach…⁴
#> * <chr>        <int> <dttm>              <chr>   <chr>   <chr>     <dbl> <chr>  
#> 1 nhdflowlin… 9.48e8 2008-03-19 23:00:00 Medium  " "     " "        6.78 180600…
#> # … with 131 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 <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>, tomeas <dbl>, …
#> 
 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               resol…¹ gnis_id gnis_…² lengt…³ reach…⁴
#> * <chr>        <int> <dttm>              <chr>   <chr>   <chr>     <dbl> <chr>  
#> 1 nhdflowline…   101 2010-11-30 23:00:00 Medium  " "     " "        3.25 120200…
#> # … with 131 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 <int>, dnlevel <int>,
#> #   uplevelpat <dbl>, uphydroseq <dbl>, dnlevelpat <dbl>, dnminorhyd <int>,
#> #   dndraincou <int>, dnhydroseq <dbl>, frommeas <int>, tomeas <dbl>, …
 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               resol…¹ gnis_id gnis_…² lengt…³ reach…⁴
#> * <chr>        <int> <dttm>              <chr>   <chr>   <chr>     <dbl> <chr>  
#> 1 nhdflowlin… 1.76e7 1999-11-18 23:00:00 Medium  269609  Atasca…    1.88 180600…
#> 2 nhdflowlin… 1.76e7 1999-11-18 23:00:00 Medium  273489  San Jo…    2.59 180600…
#> # … with 131 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 <int>, dnlevel <int>,
#> #   uplevelpat <dbl>, uphydroseq <dbl>, dnlevelpat <dbl>, dnminorhyd <int>,
#> #   dndraincou <int>, dnhydroseq <dbl>, frommeas <int>, tomeas <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               resol…¹ gnis_id gnis_…² lengt…³ reach…⁴
#>  * <chr>       <int> <dttm>              <chr>   <chr>   <chr>     <dbl> <chr>  
#>  1 nhdflowli… 1.76e7 1999-11-18 23:00:00 Medium  " "     " "       0.725 180600…
#>  2 nhdflowli… 9.48e8 2008-03-19 23:00:00 Medium  " "     " "       6.78  180600…
#>  3 nhdflowli… 9.48e8 2008-03-19 23:00:00 Medium  " "     " "       3.68  180600…
#>  4 nhdflowli… 1.76e7 1999-11-18 23:00:00 Medium  " "     " "       0.221 180600…
#>  5 nhdflowli… 1.76e7 1999-11-18 23:00:00 Medium  " "     " "       0.369 180600…
#>  6 nhdflowli… 1.76e7 2008-03-19 23:00:00 Medium  "27404… "Tecol…   0.867 180600…
#>  7 nhdflowli… 1.76e7 1999-11-18 23:00:00 Medium  " "     " "       0.833 180600…
#>  8 nhdflowli… 1.76e7 1999-11-18 23:00:00 Medium  " "     " "       0.241 180600…
#>  9 nhdflowli… 1.76e7 1999-11-18 23:00:00 Medium  " "     " "       0.91  180600…
#> 10 nhdflowli… 1.76e7 1999-11-18 23:00:00 Medium  " "     " "       0.652 180600…
#> 11 nhdflowli… 1.76e7 1999-11-18 23:00:00 Medium  " "     " "       0.715 180600…
#> 12 nhdflowli… 1.76e7 1999-11-18 23:00:00 Medium  " "     " "       0.478 180600…
#> 13 nhdflowli… 1.76e7 1999-11-18 23:00:00 Medium  " "     " "       0.058 180600…
#> 14 nhdflowli… 1.76e7 1999-11-18 23:00:00 Medium  " "     " "       0.957 180600…
#> 15 nhdflowli… 1.76e7 2008-06-04 23:00:00 Medium  " "     " "       1.23  180600…
#> 16 nhdflowli… 1.76e7 2008-06-04 23:00:00 Medium  " "     " "       1.05  180600…
#> 17 nhdflowli… 1.76e7 2008-06-04 23:00:00 Medium  " "     " "       4.42  180600…
#> 18 nhdflowli… 1.76e7 1999-11-18 23:00:00 Medium  " "     " "       0.672 180600…
#> 19 nhdflowli… 9.48e8 2010-11-30 23:00:00 Medium  " "     " "       0.218 180600…
#> # … with 131 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 <int>, dnlevel <int>,
#> #   uplevelpat <dbl>, uphydroseq <dbl>, dnlevelpat <dbl>, dnminorhyd <dbl>,
#> #   dndraincou <int>, dnhydroseq <dbl>, frommeas <dbl>, tomeas <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               resol…¹ gnis_id gnis_…² lengt…³ reach…⁴
#> * <chr>        <int> <dttm>              <chr>   <chr>   <chr>     <dbl> <chr>  
#> 1 nhdflowlin… 1.76e7 1999-11-18 23:00:00 Medium  " "     " "       0.725 180600…
#> 2 nhdflowlin… 1.76e7 1999-11-18 23:00:00 Medium  " "     " "       0.221 180600…
#> 3 nhdflowlin… 1.76e7 1999-11-18 23:00:00 Medium  " "     " "       0.369 180600…
#> 4 nhdflowlin… 1.76e7 2008-03-19 23:00:00 Medium  "27404… "Tecol…   0.867 180600…
#> 5 nhdflowlin… 1.76e7 1999-11-18 23:00:00 Medium  " "     " "       0.833 180600…
#> 6 nhdflowlin… 1.76e7 1999-11-18 23:00:00 Medium  " "     " "       0.241 180600…
#> 7 nhdflowlin… 1.76e7 1999-11-18 23:00:00 Medium  " "     " "       0.91  180600…
#> 8 nhdflowlin… 1.76e7 1999-11-18 23:00:00 Medium  " "     " "       0.652 180600…
#> # … with 131 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 <int>, dnlevel <int>,
#> #   uplevelpat <dbl>, uphydroseq <dbl>, dnlevelpat <dbl>, dnminorhyd <dbl>,
#> #   dndraincou <int>, dnhydroseq <dbl>, frommeas <int>, tomeas <int>, …
 # }