R/get_nhdplus.R
get_nhdplus.RdSubsets 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 server 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 an
EPSG:5070 Albers Equal Area projection
# \donttest{
point <- sf::st_sfc(sf::st_point(c(-119.845, 34.4146)), crs = 4326)
get_nhdplus(point)
#> 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.41791
#> Geodetic CRS: WGS 84
#> # A tibble: 1 × 139
#> objectid comid fdate resolution gnis_id gnis_name lengthkm
#> * <int> <int> <dttm> <chr> <chr> <chr> <dbl>
#> 1 2653142 948060316 2008-03-19 23:00:00 Medium " " " " 6.78
#> # ℹ 132 more variables: reachcode <chr>, flowdir <chr>, wbareacomi <int>,
#> # ftype <chr>, fcode <int>, shape_length <dbl>, streamleve <dbl>,
#> # streamorde <dbl>, streamcalc <dbl>, fromnode <dbl>, tonode <dbl>,
#> # hydroseq <dbl>, levelpathi <dbl>, pathlength <dbl>, terminalpa <dbl>,
#> # arbolatesu <dbl>, divergence <dbl>, startflag <dbl>, terminalfl <dbl>,
#> # dnlevel <dbl>, uplevelpat <dbl>, uphydroseq <dbl>, dnlevelpat <dbl>,
#> # dnminorhyd <dbl>, dndraincou <dbl>, dnhydroseq <dbl>, frommeas <dbl>, …
get_nhdplus(point, realization = "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.8253 ymax: 34.41778
#> Geodetic CRS: WGS 84
#> # A tibble: 1 × 8
#> objectid gridcode featureid sourcefc areasqkm shape_length shape_area
#> * <int> <int> <int> <chr> <dbl> <dbl> <dbl>
#> 1 2609886 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 7 fields
#> Geometry type: POLYGON
#> Dimension: XY
#> Bounding box: xmin: -119.8822 ymin: 34.40421 xmax: -119.8253 ymax: 34.41778
#> Geodetic CRS: WGS 84
#> # A tibble: 1 × 8
#> objectid gridcode featureid sourcefc areasqkm shape_length shape_area
#> * <int> <int> <int> <chr> <dbl> <dbl> <dbl>
#> 1 2609886 1482979 948060316 NHDFlowline 2.58 0.133 0.000253
#> # ℹ 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.41791
#> Geodetic CRS: WGS 84
#> # A tibble: 1 × 139
#> objectid comid fdate resolution gnis_id gnis_name lengthkm
#> * <int> <int> <dttm> <chr> <chr> <chr> <dbl>
#> 1 2653142 948060316 2008-03-19 23:00:00 Medium " " " " 6.78
#> # ℹ 132 more variables: reachcode <chr>, flowdir <chr>, wbareacomi <int>,
#> # ftype <chr>, fcode <int>, shape_length <dbl>, streamleve <dbl>,
#> # streamorde <dbl>, streamcalc <dbl>, fromnode <dbl>, tonode <dbl>,
#> # hydroseq <dbl>, levelpathi <dbl>, pathlength <dbl>, terminalpa <dbl>,
#> # arbolatesu <dbl>, divergence <dbl>, startflag <dbl>, terminalfl <dbl>,
#> # dnlevel <dbl>, uplevelpat <dbl>, uphydroseq <dbl>, dnlevelpat <dbl>,
#> # dnminorhyd <dbl>, dndraincou <dbl>, dnhydroseq <dbl>, frommeas <dbl>, …
#>
#> $outlet
#> Simple feature collection with 1 feature and 138 fields
#> Geometry type: POINT
#> Dimension: XY
#> Bounding box: xmin: -119.8295 ymin: 34.41791 xmax: -119.8295 ymax: 34.41791
#> Geodetic CRS: WGS 84
#> # A tibble: 1 × 139
#> objectid comid fdate resolution gnis_id gnis_name lengthkm
#> * <int> <int> <dttm> <chr> <chr> <chr> <dbl>
#> 1 2653142 948060316 2008-03-19 23:00:00 Medium " " " " 6.78
#> # ℹ 132 more variables: reachcode <chr>, flowdir <chr>, wbareacomi <int>,
#> # ftype <chr>, fcode <int>, shape_length <dbl>, streamleve <dbl>,
#> # streamorde <dbl>, streamcalc <dbl>, fromnode <dbl>, tonode <dbl>,
#> # hydroseq <dbl>, levelpathi <dbl>, pathlength <dbl>, terminalpa <dbl>,
#> # arbolatesu <dbl>, divergence <dbl>, startflag <dbl>, terminalfl <dbl>,
#> # dnlevel <dbl>, uplevelpat <dbl>, uphydroseq <dbl>, dnlevelpat <dbl>,
#> # dnminorhyd <dbl>, dndraincou <dbl>, dnhydroseq <dbl>, frommeas <dbl>, …
#>
get_nhdplus(comid = 101)
#> Simple feature collection with 1 feature and 138 fields
#> Geometry type: LINESTRING
#> Dimension: XY
#> Bounding box: xmin: -94.64845 ymin: 31.08381 xmax: -94.62997 ymax: 31.09916
#> Geodetic CRS: WGS 84
#> # A tibble: 1 × 139
#> objectid comid fdate resolution gnis_id gnis_name lengthkm
#> * <int> <int> <dttm> <chr> <chr> <chr> <dbl>
#> 1 1915835 101 2010-11-30 23:00:00 Medium " " " " 3.25
#> # ℹ 132 more variables: reachcode <chr>, flowdir <chr>, wbareacomi <int>,
#> # ftype <chr>, fcode <int>, shape_length <dbl>, streamleve <dbl>,
#> # streamorde <dbl>, streamcalc <dbl>, fromnode <dbl>, tonode <dbl>,
#> # hydroseq <dbl>, levelpathi <dbl>, pathlength <dbl>, terminalpa <dbl>,
#> # arbolatesu <dbl>, divergence <dbl>, startflag <dbl>, terminalfl <dbl>,
#> # dnlevel <dbl>, uplevelpat <dbl>, uphydroseq <dbl>, dnlevelpat <dbl>,
#> # dnminorhyd <dbl>, dndraincou <dbl>, dnhydroseq <dbl>, frommeas <dbl>, …
get_nhdplus(nwis = c(11120000, 11120500))
#> Simple feature collection with 2 features and 138 fields
#> Geometry type: LINESTRING
#> Dimension: XY
#> Bounding box: xmin: -119.8296 ymin: 34.42015 xmax: -119.8057 ymax: 34.47473
#> Geodetic CRS: WGS 84
#> # A tibble: 2 × 139
#> objectid comid fdate resolution gnis_id gnis_name lengthkm
#> * <int> <int> <dttm> <chr> <chr> <chr> <dbl>
#> 1 2653564 17595429 1999-11-18 23:00:00 Medium 269609 Atascadero … 1.88
#> 2 2653136 17596109 1999-11-18 23:00:00 Medium 273489 San Jose Cr… 2.59
#> # ℹ 132 more variables: reachcode <chr>, flowdir <chr>, wbareacomi <int>,
#> # ftype <chr>, fcode <int>, shape_length <dbl>, streamleve <dbl>,
#> # streamorde <dbl>, streamcalc <dbl>, fromnode <dbl>, tonode <dbl>,
#> # hydroseq <dbl>, levelpathi <dbl>, pathlength <dbl>, terminalpa <dbl>,
#> # arbolatesu <dbl>, divergence <dbl>, startflag <dbl>, terminalfl <dbl>,
#> # dnlevel <dbl>, uplevelpat <dbl>, uphydroseq <dbl>, dnlevelpat <dbl>,
#> # dnminorhyd <dbl>, dndraincou <dbl>, dnhydroseq <dbl>, frommeas <dbl>, …
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)
#> 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.45476
#> Geodetic CRS: WGS 84
#> # A tibble: 19 × 139
#> objectid comid fdate resolution gnis_id gnis_name lengthkm
#> * <int> <int> <dttm> <chr> <chr> <chr> <dbl>
#> 1 2653636 17595401 1999-11-18 23:00:00 Medium " " " " 0.478
#> 2 2653612 17595409 1999-11-18 23:00:00 Medium " " " " 0.369
#> 3 2653634 17595411 1999-11-18 23:00:00 Medium " " " " 0.058
#> 4 2653732 17595413 2008-06-04 23:00:00 Medium " " " " 4.42
#> 5 2653718 17595415 2008-06-04 23:00:00 Medium " " " " 1.23
#> 6 2653618 17595425 1999-11-18 23:00:00 Medium " " " " 0.221
#> 7 2653744 17595433 1999-11-18 23:00:00 Medium " " " " 0.672
#> 8 2653613 17596135 2008-03-19 23:00:00 Medium "274049" "Tecolot… 0.867
#> 9 2653637 17596139 1999-11-18 23:00:00 Medium " " " " 0.957
#> 10 2653617 17596141 1999-11-18 23:00:00 Medium " " " " 0.652
#> 11 2653611 17596143 1999-11-18 23:00:00 Medium " " " " 0.241
#> 12 2653635 17596145 1999-11-18 23:00:00 Medium " " " " 0.715
#> 13 2653616 17596147 1999-11-18 23:00:00 Medium " " " " 0.91
#> 14 2653133 17596149 1999-11-18 23:00:00 Medium " " " " 0.725
#> 15 2653610 17596151 1999-11-18 23:00:00 Medium " " " " 0.833
#> 16 2653731 17596217 2008-06-04 23:00:00 Medium " " " " 1.05
#> 17 2653756 948060315 2010-11-30 23:00:00 Medium " " " " 0.218
#> 18 2653142 948060316 2008-03-19 23:00:00 Medium " " " " 6.78
#> 19 2653143 948060317 2008-03-19 23:00:00 Medium " " " " 3.68
#> # ℹ 132 more variables: reachcode <chr>, flowdir <chr>, wbareacomi <int>,
#> # ftype <chr>, fcode <int>, shape_length <dbl>, streamleve <dbl>,
#> # streamorde <dbl>, streamcalc <dbl>, fromnode <dbl>, tonode <dbl>,
#> # hydroseq <dbl>, levelpathi <dbl>, pathlength <dbl>, terminalpa <dbl>,
#> # arbolatesu <dbl>, divergence <dbl>, startflag <dbl>, terminalfl <dbl>,
#> # dnlevel <dbl>, uplevelpat <dbl>, uphydroseq <dbl>, dnlevelpat <dbl>,
#> # dnminorhyd <dbl>, dndraincou <dbl>, dnhydroseq <dbl>, frommeas <dbl>, …
get_nhdplus(area, realization = "flowline", streamorder = 3)
#> Simple feature collection with 8 features and 138 fields
#> Geometry type: LINESTRING
#> Dimension: XY
#> Bounding box: xmin: -119.8528 ymin: 34.41656 xmax: -119.8295 ymax: 34.42814
#> Geodetic CRS: WGS 84
#> # A tibble: 8 × 139
#> objectid comid fdate resolution gnis_id gnis_name lengthkm
#> * <int> <int> <dttm> <chr> <chr> <chr> <dbl>
#> 1 2653612 17595409 1999-11-18 23:00:00 Medium " " " " 0.369
#> 2 2653618 17595425 1999-11-18 23:00:00 Medium " " " " 0.221
#> 3 2653613 17596135 2008-03-19 23:00:00 Medium "274049" "Tecolotit… 0.867
#> 4 2653617 17596141 1999-11-18 23:00:00 Medium " " " " 0.652
#> 5 2653611 17596143 1999-11-18 23:00:00 Medium " " " " 0.241
#> 6 2653616 17596147 1999-11-18 23:00:00 Medium " " " " 0.91
#> 7 2653133 17596149 1999-11-18 23:00:00 Medium " " " " 0.725
#> 8 2653610 17596151 1999-11-18 23:00:00 Medium " " " " 0.833
#> # ℹ 132 more variables: reachcode <chr>, flowdir <chr>, wbareacomi <int>,
#> # ftype <chr>, fcode <int>, shape_length <dbl>, streamleve <dbl>,
#> # streamorde <dbl>, streamcalc <dbl>, fromnode <dbl>, tonode <dbl>,
#> # hydroseq <dbl>, levelpathi <dbl>, pathlength <dbl>, terminalpa <dbl>,
#> # arbolatesu <dbl>, divergence <dbl>, startflag <dbl>, terminalfl <dbl>,
#> # dnlevel <dbl>, uplevelpat <dbl>, uphydroseq <dbl>, dnlevelpat <dbl>,
#> # dnminorhyd <dbl>, dndraincou <dbl>, dnhydroseq <dbl>, frommeas <dbl>, …
# }