header_tag.html

Skip to contents

Provides a formal client to the USGS Network Linked Data Index.

Usage

findNLDI(
  comid = NULL,
  nwis = NULL,
  wqp = NULL,
  huc12 = NULL,
  location = NULL,
  origin = NULL,
  nav = NULL,
  find = c("flowlines"),
  distance_km = 100,
  no_sf = FALSE,
  warn = TRUE
)

Arguments

comid

numeric or character. An NHDPlusV2 COMID

nwis

numeric or character. A USGS NWIS surface water siteID

wqp

numeric or character. A water quality point ID

huc12

numeric or character. A WBD HUC12 unit ID

location

numeric vector. Coordinate pair in WGS84 SRS ordered lng/lat (X,Y)

origin

named list. Specifying a feature type and ID (e.g. list("comid" = 101))

nav

character vector. where to navigate from the starting point. Options include along the upper mainsteam (UM), upstream tributary (UT), downstream mainstem (DM) and downstream divergences (DD). You may select one or more of the abbreviations ("UM", "UT", DM", "DD").

find

character vector. Define what resources to find along the navigation path(s) (see get_nldi_sources()$source). Can also include 'basin' or 'flowline', which will return the upstream basin of the starting feature or flowlines along the navigation respectively. The default is "flowlines". If you provide any other resource, AND want flowlines, then flowlines must be explicitly requested.

distance_km

numeric. Define how far to look along the navigation path in kilometers (default = 100)

no_sf

if available, should sf be used for parsing, defaults to TRUE if sf is locally installed

warn

(default TRUE) should warnings be printed

Value

a list of data.frames if sf is not installed, a list of sf objects if it is

Details

The function is useful for topology and location based feature discovery. A user must specify an origin feature, optional navigation direction(s) along the network, as well as features to identify along the navigated paths. Valid starting options can be given by one of the following arguments: comid, nwis, huc12, wqp, location, and start.

Examples

# \donttest{
# Find Features / Define origin features

## Find feature by COMID
findNLDI(comid = 101)
#> $origin
#> Simple feature collection with 1 feature and 4 fields
#> Geometry type: LINESTRING
#> Dimension:     XYZ
#> Bounding box:  xmin: -94.64845 ymin: 31.0838 xmax: -94.62997 ymax: 31.09915
#> z_range:       zmin: 0 zmax: 72.6701
#> Geodetic CRS:  WGS 84
#> # A tibble: 1 × 5
#>   sourceName    identifier comid reachcode                              geometry
#>   <chr>         <chr>      <int> <chr>                          <LINESTRING [°]>
#> 1 NHDPlus comid 101          101 12020002001025 Z (-94.64845 31.09915 72.6701, …
#> 

## Find feature by NWIS ID
findNLDI(nwis = "11120000")
#> $origin
#> Simple feature collection with 1 feature and 8 fields
#> Geometry type: POINT
#> Dimension:     XY
#> Bounding box:  xmin: -119.8118 ymin: 34.42472 xmax: -119.8118 ymax: 34.42472
#> Geodetic CRS:  WGS 84
#> # A tibble: 1 × 9
#>   sourceName               identifier  comid name  reachcode measure     X     Y
#>   <chr>                    <chr>       <int> <chr> <chr>       <dbl> <dbl> <dbl>
#> 1 NWIS Surface Water Sites USGS-1112… 1.76e7 ATAS… 18060013…    92.4 -120.  34.4
#> # ℹ 1 more variable: geometry <POINT [°]>
#> 


## Find feature by LOCATION
findNLDI(location = c(-115, 40))
#> $origin
#> Simple feature collection with 1 feature and 4 fields
#> Geometry type: LINESTRING
#> Dimension:     XYZ
#> Bounding box:  xmin: -115.0326 ymin: 40.04013 xmax: -115.0182 ymax: 40.05183
#> z_range:       zmin: 0 zmax: 90.0054
#> Geodetic CRS:  WGS 84
#> # A tibble: 1 × 5
#>   sourceName    identifier     comid reachcode                          geometry
#>   <chr>         <chr>          <int> <chr>                      <LINESTRING [°]>
#> 1 NHDPlus comid 946060315  946060315 16060007001558 Z (-115.0182 40.05183 90.00…
#> 

## GENERAL ORIGIN: COMID
findNLDI(origin = list("comid" = 101))
#> $origin
#> Simple feature collection with 1 feature and 4 fields
#> Geometry type: LINESTRING
#> Dimension:     XYZ
#> Bounding box:  xmin: -94.64845 ymin: 31.0838 xmax: -94.62997 ymax: 31.09915
#> z_range:       zmin: 0 zmax: 72.6701
#> Geodetic CRS:  WGS 84
#> # A tibble: 1 × 5
#>   sourceName    identifier comid reachcode                              geometry
#>   <chr>         <chr>      <int> <chr>                          <LINESTRING [°]>
#> 1 NHDPlus comid 101          101 12020002001025 Z (-94.64845 31.09915 72.6701, …
#> 

# Navigation (flowlines will be returned if find is unspecified)
# UPPER MAINSTEM of USGS-11120000
findNLDI(nwis = "11120000", nav = "UM")
#> $origin
#> Simple feature collection with 1 feature and 8 fields
#> Geometry type: POINT
#> Dimension:     XY
#> Bounding box:  xmin: -119.8118 ymin: 34.42472 xmax: -119.8118 ymax: 34.42472
#> Geodetic CRS:  WGS 84
#> # A tibble: 1 × 9
#>   sourceName               identifier  comid name  reachcode measure     X     Y
#>   <chr>                    <chr>       <int> <chr> <chr>       <dbl> <dbl> <dbl>
#> 1 NWIS Surface Water Sites USGS-1112… 1.76e7 ATAS… 18060013…    92.4 -120.  34.4
#> # ℹ 1 more variable: geometry <POINT [°]>
#> 
#> $UM_flowlines
#> Simple feature collection with 4 features and 1 field
#> Geometry type: LINESTRING
#> Dimension:     XYZ
#> Bounding box:  xmin: -119.8296 ymin: 34.42015 xmax: -119.7607 ymax: 34.46831
#> z_range:       zmin: 0 zmax: 100
#> Geodetic CRS:  WGS 84
#> # A tibble: 4 × 2
#>   nhdplus_comid                                                         geometry
#>           <int>                                                 <LINESTRING [°]>
#> 1      17595361 Z (-119.7755 34.43447 100, -119.7761 34.43406 93.341, -119.7782…
#> 2      17595395 Z (-119.7859 34.43139 100, -119.7861 34.43114 98.6906, -119.786…
#> 3      17595429 Z (-119.8104 34.42513 100, -119.8112 34.42476 95.5424, -119.812…
#> 4      17596117 Z (-119.7631 34.46831 100, -119.7626 34.46781 98.4319, -119.762…
#> 

# MULTI-REQUEST
# UPPER MAINSTEM and TRIBUTARY of USGS-11120000
findNLDI(nwis = "11120000", nav = c("UT", "UM"))
#> $origin
#> Simple feature collection with 1 feature and 8 fields
#> Geometry type: POINT
#> Dimension:     XY
#> Bounding box:  xmin: -119.8118 ymin: 34.42472 xmax: -119.8118 ymax: 34.42472
#> Geodetic CRS:  WGS 84
#> # A tibble: 1 × 9
#>   sourceName               identifier  comid name  reachcode measure     X     Y
#>   <chr>                    <chr>       <int> <chr> <chr>       <dbl> <dbl> <dbl>
#> 1 NWIS Surface Water Sites USGS-1112… 1.76e7 ATAS… 18060013…    92.4 -120.  34.4
#> # ℹ 1 more variable: geometry <POINT [°]>
#> 
#> $UT_flowlines
#> Simple feature collection with 25 features and 1 field
#> Geometry type: LINESTRING
#> Dimension:     XYZ
#> Bounding box:  xmin: -119.8296 ymin: 34.42015 xmax: -119.7332 ymax: 34.51769
#> z_range:       zmin: 0 zmax: 100
#> Geodetic CRS:  WGS 84
#> # A tibble: 25 × 2
#>    nhdplus_comid                                                        geometry
#>            <int>                                                <LINESTRING [°]>
#>  1      17594365 Z (-119.7838 34.51769 100, -119.784 34.51746 99.1194, -119.784…
#>  2      17594367 Z (-119.7743 34.50875 100, -119.7745 34.5083 97.342, -119.7748…
#>  3      17594369 Z (-119.7653 34.50623 100, -119.7647 34.50524 96.384, -119.764…
#>  4      17594371 Z (-119.7332 34.50132 100, -119.7359 34.50207 95.2077, -119.73…
#>  5      17595165 Z (-119.7792 34.50001 43.7549, -119.7793 34.49987 42.9633, -11…
#>  6      17595167 Z (-119.786 34.50001 26.6084, -119.7854 34.49886 22.6877, -119…
#>  7      17595199 Z (-119.7552 34.49383 100, -119.7554 34.49262 92.3911, -119.75…
#>  8      17595201 Z (-119.7638 34.5 77.1749, -119.7639 34.49912 74.2434, -119.76…
#>  9      17595217 Z (-119.7817 34.49282 100, -119.783 34.49012 86.926, -119.783 …
#> 10      17595219 Z (-119.7944 34.49916 100, -119.7947 34.4963 88.435, -119.7946…
#> # ℹ 15 more rows
#> 
#> $UM_flowlines
#> Simple feature collection with 4 features and 1 field
#> Geometry type: LINESTRING
#> Dimension:     XYZ
#> Bounding box:  xmin: -119.8296 ymin: 34.42015 xmax: -119.7607 ymax: 34.46831
#> z_range:       zmin: 0 zmax: 100
#> Geodetic CRS:  WGS 84
#> # A tibble: 4 × 2
#>   nhdplus_comid                                                         geometry
#>           <int>                                                 <LINESTRING [°]>
#> 1      17595361 Z (-119.7755 34.43447 100, -119.7761 34.43406 93.341, -119.7782…
#> 2      17595395 Z (-119.7859 34.43139 100, -119.7861 34.43114 98.6906, -119.786…
#> 3      17595429 Z (-119.8104 34.42513 100, -119.8112 34.42476 95.5424, -119.812…
#> 4      17596117 Z (-119.7631 34.46831 100, -119.7626 34.46781 98.4319, -119.762…
#> 

# Discover Features(flowlines will not be returned unless included in find)

## Find feature(s) on the upper tributary of USGS-11120000
findNLDI(nwis = "11120000", nav = "UT", find = c("nwis"))
#> $origin
#> Simple feature collection with 1 feature and 8 fields
#> Geometry type: POINT
#> Dimension:     XY
#> Bounding box:  xmin: -119.8118 ymin: 34.42472 xmax: -119.8118 ymax: 34.42472
#> Geodetic CRS:  WGS 84
#> # A tibble: 1 × 9
#>   sourceName               identifier  comid name  reachcode measure     X     Y
#>   <chr>                    <chr>       <int> <chr> <chr>       <dbl> <dbl> <dbl>
#> 1 NWIS Surface Water Sites USGS-1112… 1.76e7 ATAS… 18060013…    92.4 -120.  34.4
#> # ℹ 1 more variable: geometry <POINT [°]>
#> 
#> $UT_nwissite
#> Simple feature collection with 3 features and 8 fields
#> Geometry type: POINT
#> Dimension:     XY
#> Bounding box:  xmin: -119.8118 ymin: 34.42472 xmax: -119.7843 ymax: 34.445
#> Geodetic CRS:  WGS 84
#> # A tibble: 3 × 9
#>   sourceName               identifier  comid name  reachcode measure     X     Y
#>   <chr>                    <chr>       <int> <chr> <chr>       <dbl> <dbl> <dbl>
#> 1 NWIS Surface Water Sites USGS-1112… 1.76e7 ATAS… 18060013…   92.4  -120.  34.4
#> 2 NWIS Surface Water Sites USGS-1111… 1.76e7 ATAS… 18060013…    3.14 -120.  34.4
#> 3 NWIS Surface Water Sites USGS-1111… 1.76e7 MARI… 18060013…   14.3  -120.  34.4
#> # ℹ 1 more variable: geometry <POINT [°]>
#> 

## Find upstream basin boundary and  of USGS-11120000
findNLDI(nwis = "11120000", find = "basin")
#> $origin
#> Simple feature collection with 1 feature and 8 fields
#> Geometry type: POINT
#> Dimension:     XY
#> Bounding box:  xmin: -119.8118 ymin: 34.42472 xmax: -119.8118 ymax: 34.42472
#> Geodetic CRS:  WGS 84
#> # A tibble: 1 × 9
#>   sourceName               identifier  comid name  reachcode measure     X     Y
#>   <chr>                    <chr>       <int> <chr> <chr>       <dbl> <dbl> <dbl>
#> 1 NWIS Surface Water Sites USGS-1112… 1.76e7 ATAS… 18060013…    92.4 -120.  34.4
#> # ℹ 1 more variable: geometry <POINT [°]>
#> 
#> $basin
#> Simple feature collection with 1 feature and 0 fields
#> Geometry type: POLYGON
#> Dimension:     XY
#> Bounding box:  xmin: -119.8295 ymin: 34.41806 xmax: -119.7307 ymax: 34.52038
#> Geodetic CRS:  WGS 84
#> # A tibble: 1 × 1
#>                                                                         geometry
#>                                                                    <POLYGON [°]>
#> 1 ((-119.7732 34.43021, -119.7742 34.42717, -119.7832 34.42023, -119.8045 34.41…
#> 

# Control Distance
## Limit search to 50 km
findNLDI(comid = 101, nav = "DM", find = c("nwis", "flowlines"), distance_km = 50)
#> $origin
#> Simple feature collection with 1 feature and 4 fields
#> Geometry type: LINESTRING
#> Dimension:     XYZ
#> Bounding box:  xmin: -94.64845 ymin: 31.0838 xmax: -94.62997 ymax: 31.09915
#> z_range:       zmin: 0 zmax: 72.6701
#> Geodetic CRS:  WGS 84
#> # A tibble: 1 × 5
#>   sourceName    identifier comid reachcode                              geometry
#>   <chr>         <chr>      <int> <chr>                          <LINESTRING [°]>
#> 1 NHDPlus comid 101          101 12020002001025 Z (-94.64845 31.09915 72.6701, …
#> 
#> $DM_nwissite
#> Simple feature collection with 1 feature and 8 fields
#> Geometry type: POINT
#> Dimension:     XY
#> Bounding box:  xmin: -94.39944 ymin: 31.025 xmax: -94.39944 ymax: 31.025
#> Geodetic CRS:  WGS 84
#> # A tibble: 1 × 9
#>   sourceName               identifier  comid name  reachcode measure     X     Y
#>   <chr>                    <chr>       <chr> <chr> <chr>     <chr>   <dbl> <dbl>
#> 1 NWIS Surface Water Sites USGS-08033… 1109… Nech… 12020003… 68.359… -94.4  31.0
#> # ℹ 1 more variable: geometry <POINT [°]>
#> 
#> $DM_flowlines
#> Simple feature collection with 20 features and 1 field
#> Geometry type: LINESTRING
#> Dimension:     XYZ
#> Bounding box:  xmin: -94.64845 ymin: 31.00305 xmax: -94.37394 ymax: 31.09915
#> z_range:       zmin: 0 zmax: 100
#> Geodetic CRS:  WGS 84
#> # A tibble: 20 × 2
#>    nhdplus_comid                                                        geometry
#>            <int>                                                <LINESTRING [°]>
#>  1           101 Z (-94.64845 31.09915 72.6701, -94.64803 31.09871 71.2638, -94…
#>  2       1078719 Z (-94.62997 31.0838 100, -94.62957 31.08367 98.9594, -94.6288…
#>  3       1078721 Z (-94.61139 31.07963 100, -94.61205 31.07897 57.0349, -94.612…
#>  4       1078725 Z (-94.61216 31.07787 100, -94.61085 31.07759 90.1306, -94.608…
#>  5       1078733 Z (-94.60537 31.07764 100, -94.60502 31.07796 97.8255, -94.604…
#>  6       1078739 Z (-94.59281 31.07283 100, -94.59113 31.07301 93.4155, -94.588…
#>  7       1078769 Z (-94.56965 31.06817 100, -94.56946 31.06814 99.5524, -94.569…
#>  8       1078783 Z (-94.53857 31.05436 100, -94.53809 31.05429 97.0541, -94.537…
#>  9       1078807 Z (-94.53096 31.05568 100, -94.53093 31.05499 97.7031, -94.530…
#> 10       1078835 Z (-94.51641 31.04992 100, -94.51633 31.04939 97.5839, -94.515…
#> 11       1078885 Z (-94.49899 31.04272 100, -94.49737 31.04286 95.1722, -94.496…
#> 12       1078897 Z (-94.48568 31.03226 100, -94.48568 31.03155 97.5999, -94.485…
#> 13       1079065 Z (-94.50175 31.04448 100, -94.50175 31.04438 97.2613, -94.501…
#> 14       1109651 Z (-94.39707 31.02849 100, -94.39696 31.02906 98.4064, -94.396…
#> 15       1109655 Z (-94.40199 31.02606 100, -94.40188 31.02606 98.8883, -94.401…
#> 16       1109665 Z (-94.43287 31.01461 100, -94.43279 31.0147 99.6587, -94.4313…
#> 17       1109669 Z (-94.43277 31.01319 100, -94.43402 31.01303 86.0362, -94.434…
#> 18       1109675 Z (-94.4342 31.00714 100, -94.43401 31.00755 95.2553, -94.4340…
#> 19       1109679 Z (-94.45777 31.03345 100, -94.45771 31.033 99.2033, -94.45779…
#> 20       1109681 Z (-94.45096 31.00347 100, -94.45066 31.00314 97.3439, -94.450…
#> 
# }