R/get_nhdplus.R
get_nhdplus.Rd
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
)
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.
numeric or character. Search for NHD features by COMID(s)
numeric or character. Search for NHD features by collocated NWIS identifiers
character. What realization to return. Default is flowline and options include: outlet, flowline, catchment, and all
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.
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.
sfc a single, or list, of simple feature objects
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 (either input or default).
All buffer and distance operations are handled internally using in
EPSG:5070 Albers Equal Area projection
# \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 137 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 × 138
#> comid fdate resolution gnis_id gnis_name lengthkm reachcode
#> <int> <dttm> <chr> <chr> <chr> <dbl> <chr>
#> 1 948060316 2008-03-19 23:00:00 Medium " " " " 6.78 180600130…
#> # ℹ 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 6 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 × 7
#> gridcode featureid sourcefc areasqkm shape_length shape_area
#> <int> <int> <chr> <dbl> <dbl> <dbl>
#> 1 1482979 948060316 NHDFlowline 2.58 0.133 0.000253
#> # ℹ 1 more variable: geometry <POLYGON [°]>
get_nhdplus(point, realization = "all")
#> $catchment
#> Simple feature collection with 1 feature and 6 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 × 7
#> gridcode featureid sourcefc areasqkm shape_length shape_area
#> <int> <int> <chr> <dbl> <dbl> <dbl>
#> 1 1482979 948060316 NHDFlowline 2.58 0.133 0.000253
#> # ℹ 1 more variable: geometry <POLYGON [°]>
#>
#> $flowline
#> Simple feature collection with 1 feature and 137 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 × 138
#> comid fdate resolution gnis_id gnis_name lengthkm reachcode
#> <int> <dttm> <chr> <chr> <chr> <dbl> <chr>
#> 1 948060316 2008-03-19 23:00:00 Medium " " " " 6.78 180600130…
#> # ℹ 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 137 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 × 138
#> comid fdate resolution gnis_id gnis_name lengthkm reachcode
#> * <int> <dttm> <chr> <chr> <chr> <dbl> <chr>
#> 1 948060316 2008-03-19 23:00:00 Medium " " " " 6.78 180600130…
#> # ℹ 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 137 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 × 138
#> comid fdate resolution gnis_id gnis_name lengthkm reachcode
#> <int> <dttm> <chr> <chr> <chr> <dbl> <chr>
#> 1 101 2010-11-30 23:00:00 Medium " " " " 3.25 12020002001025
#> # ℹ 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 137 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 × 138
#> comid fdate resolution gnis_id gnis_name lengthkm reachcode
#> <int> <dttm> <chr> <chr> <chr> <dbl> <chr>
#> 1 17595429 1999-11-18 23:00:00 Medium 269609 Atascadero… 1.88 18060013…
#> 2 17596109 1999-11-18 23:00:00 Medium 273489 San Jose C… 2.59 18060013…
#> # ℹ 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 137 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 × 138
#> comid fdate resolution gnis_id gnis_name lengthkm reachcode
#> <int> <dttm> <chr> <chr> <chr> <dbl> <chr>
#> 1 17596149 1999-11-18 23:00:00 Medium " " " " 0.725 18060013…
#> 2 948060316 2008-03-19 23:00:00 Medium " " " " 6.78 18060013…
#> 3 948060317 2008-03-19 23:00:00 Medium " " " " 3.68 18060013…
#> 4 17595425 1999-11-18 23:00:00 Medium " " " " 0.221 18060013…
#> 5 17595409 1999-11-18 23:00:00 Medium " " " " 0.369 18060013…
#> 6 17596135 2008-03-19 23:00:00 Medium "27404… "Tecolot… 0.867 18060013…
#> 7 17596151 1999-11-18 23:00:00 Medium " " " " 0.833 18060013…
#> 8 17596143 1999-11-18 23:00:00 Medium " " " " 0.241 18060013…
#> 9 17596147 1999-11-18 23:00:00 Medium " " " " 0.91 18060013…
#> 10 17596141 1999-11-18 23:00:00 Medium " " " " 0.652 18060013…
#> 11 17596145 1999-11-18 23:00:00 Medium " " " " 0.715 18060013…
#> 12 17595401 1999-11-18 23:00:00 Medium " " " " 0.478 18060013…
#> 13 17595411 1999-11-18 23:00:00 Medium " " " " 0.058 18060013…
#> 14 17596139 1999-11-18 23:00:00 Medium " " " " 0.957 18060013…
#> 15 17595415 2008-06-04 23:00:00 Medium " " " " 1.23 18060013…
#> 16 17596217 2008-06-04 23:00:00 Medium " " " " 1.05 18060013…
#> 17 17595413 2008-06-04 23:00:00 Medium " " " " 4.42 18060013…
#> 18 17595433 1999-11-18 23:00:00 Medium " " " " 0.672 18060013…
#> 19 948060315 2010-11-30 23:00:00 Medium " " " " 0.218 18060013…
#> # ℹ 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 137 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 × 138
#> comid fdate resolution gnis_id gnis_name lengthkm reachcode
#> <int> <dttm> <chr> <chr> <chr> <dbl> <chr>
#> 1 17596149 1999-11-18 23:00:00 Medium " " " " 0.725 18060013…
#> 2 17595425 1999-11-18 23:00:00 Medium " " " " 0.221 18060013…
#> 3 17595409 1999-11-18 23:00:00 Medium " " " " 0.369 18060013…
#> 4 17596135 2008-03-19 23:00:00 Medium "274049" "Tecoloti… 0.867 18060013…
#> 5 17596151 1999-11-18 23:00:00 Medium " " " " 0.833 18060013…
#> 6 17596143 1999-11-18 23:00:00 Medium " " " " 0.241 18060013…
#> 7 17596147 1999-11-18 23:00:00 Medium " " " " 0.91 18060013…
#> 8 17596141 1999-11-18 23:00:00 Medium " " " " 0.652 18060013…
#> # ℹ 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>, …
# }