<h2>Introduction</h2>
<p>The Hydro <a href="https://cida.usgs.gov/nldi/about">Network-Linked Data Index (NLDI)</a> is a system that can index data to <a href="http://www.horizon-systems.com/NHDPlus/V2NationalData.php">NHDPlus V2</a> catchments and offers a search service to discover indexed information. Data linked to the NLDI includes <a href="https://waterdata.usgs.gov/nwis/rt">active NWIS stream gages</a>, <a href="https://www.waterqualitydata.us/">water quality portal sites</a>, and <a href="https://www.sciencebase.gov/catalog/item/5762b664e4b07657d19a71ea">outlets of HUC12 watersheds</a>. The NLDI is a core product of the <a href="http://acwi.gov/spatial/owdi/">Open Water Data Initiative</a> and is being developed as <a href="https://github.com/ACWI-SSWD">an open source project.</a> coordinated through the <a href="http://acwi.gov/spatial">Advisory Committee on Water Information (ACWI) Subcommittee on Spatial Water Data</a>.</p>
<p>In this blog post, we introduce the basic functions of the NLDI and show how to use it as a data discovery and access tool in R. The first section describes the operations available from the <a href="https://cida.usgs.gov/nldi/swagger-ui.html">NLDI’s Web API</a>. The second section shows how to map NLDI data and how to use the NLDI to discover data to be accessed with the <a href="https://github.com/USGS-R/dataRetrieval">dataRetrieval</a> R- package.</p>
<p>Below, text highlighting is used in six ways:</p>
<p>1) The names of API parameters such as <code>{featureSource}</code><br>
2) Example values of API parameters such as: <code>USGS-08279500</code><br>
3) API operation names: <strong>navigation</strong> and <strong>basin</strong><br>
4) API request names such as: getDataSources<br>
5) R functions such as: <strong>readOGR</strong><br>
6) Other specific strings such as “siteNumber”</p>
<h2>The NLDI Web API</h2>
<p>The NLDI’s Web API follows a loosely RESTful design and is documented with <a href="http://swagger.io/">swagger</a> documentation which can <a href="https://cida.usgs.gov/nldi/swagger-ui.html">be found here.</a> Every request to get data from the NLDI starts from a given network linked feature.</p>
<h3>Feature Sources</h3>
<p>Available network linked feature sources (<code>{featureSource}</code>s) can be found from the <a href="https://cida.usgs.gov/nldi/swagger-ui.html#!/lookup-controller/getDataSourcesUsingGET">getDataSources request.</a> (hint: Click the “try it out” button on the swagger page!) These are the collections of network linked features the NLDI knows about. Think of them as watershed outlets that can be used as a starting point. For this demo, we’ll use NWIS Stream Gages as the <code>{featureSource}</code>. As a note for later, <code>{featureSource}</code> here is the same as the <code>{dataSource}</code> described below.</p>
<h3>Feature IDs</h3>
<p>For now, the particular <code>{featureID}</code> to be accessed from a given <code>{featureSource}</code> needs to be found outside the NLDI, so the <a href="https://cida.usgs.gov/nldi/swagger-ui.html#!/lookup-controller/getFeaturesUsingGET_1">getFeatures</a> request doesn’t return anything. So let’s use a <a href="https://www.usgs.gov/news/first-usgs-streamgage-records-125-years-measuring-new-mexico%E2%80%99s-vital-water-resources">well known NWIS Streamgage</a> on the <a href="https://waterdata.usgs.gov/nwis/inventory/?site_no=08279500&agency_cd=USGS">Rio Grande at Embudo NM</a> as our starting point.</p>
<p></p>
<h3>Indexed Features</h3>
<p>We can use the <a href="https://cida.usgs.gov/nldi/swagger-ui.html#!/lookup-controller/getRegisteredFeatureUsingGET">getRegisteredFeature</a> request to see this feature. Enter <code>nwissite</code> and <code>USGS-08279500</code> in the <code>{featureSource}</code> and <code>{featureID}</code>, respectively, in the <a href="https://cida.usgs.gov/nldi/swagger-ui.html#!/lookup-controller/getRegisteredFeatureUsingGET">swagger demo page.</a> You can also see this in your browser at this url:
<a href="https://cida.usgs.gov/nldi/nwissite/USGS-08279500">https://cida.usgs.gov/nldi/nwissite/USGS-08279500</a>
The response contains the location of the feature, is in <a href="http://geojson.org/">geojson</a>, and looks like:</p>
<pre><code>{
  &quot;type&quot;: &quot;FeatureCollection&quot;,
  &quot;features&quot;: [
    {
      &quot;type&quot;: &quot;Feature&quot;,
      &quot;geometry&quot;: {
        &quot;type&quot;: &quot;Point&quot;,
        &quot;coordinates&quot;: [
          -105.9639722,
          36.20555556
        ]
      },
      &quot;properties&quot;: {
        &quot;source&quot;: &quot;nwissite&quot;,
        &quot;sourceName&quot;: &quot;NWIS Sites&quot;,
        &quot;identifier&quot;: &quot;USGS-08279500&quot;,
        &quot;name&quot;: &quot;RIO GRANDE AT EMBUDO, NM&quot;,
        &quot;uri&quot;: &quot;https://waterdata.usgs.gov/nwis/inventory?agency_code=USGS&amp;site_no=08279500&quot;,
        &quot;comid&quot;: &quot;17864756&quot;,
        &quot;navigation&quot;: &quot;https://cida.usgs.gov/nldi/nwissite/USGS-08279500/navigate&quot;
      }
    }
  ]
}
</code></pre>
<h3>Navigation</h3>
<p>The <strong>navigation</strong> property of the returned feature is a url for the <a href="https://cida.usgs.gov/nldi/swagger-ui.html#!/lookup-controller/getNavigationTypesUsingGET">getNavigationTypes</a> request. This request provides four <strong>navigation</strong> options as shown below. Each of these URLs returns the NHDPlus flowlines for the navigation type.</p>
<pre><code>{
  &quot;upstreamMain&quot;: &quot;https://cida.usgs.gov/nldi/nwissite/USGS-08279500/navigate/UM&quot;,
  &quot;upstreamTributaries&quot;: &quot;https://cida.usgs.gov/nldi/nwissite/USGS-08279500/navigate/UT&quot;,
  &quot;downstreamMain&quot;: &quot;https://cida.usgs.gov/nldi/nwissite/USGS-08279500/navigate/DM&quot;,
  &quot;downstreamDiversions&quot;: &quot;https://cida.usgs.gov/nldi/nwissite/USGS-08279500/navigate/DD&quot;
}
</code></pre>
<h3>Get Flowlines from Navigation</h3>
<p>Each of the URLs found via the getNavigationTypes request is a complete <a href="https://cida.usgs.gov/nldi/swagger-ui.html#!/linked-data-controller/getFlowlinesUsingGET">getFlowlines</a> request. This request has some optional input parameters. The most useful being <code>{distance}</code>, which allows specification of a distance to navigate in km. So, for example, we can use this to retrieve 150km of upstream mainstem flowlines from the NWIS gage 08279500 with a request like:
<a href="https://cida.usgs.gov/nldi/nwissite/USGS-08279500/navigate/UM?distance=150">https://cida.usgs.gov/nldi/nwissite/USGS-08279500/navigate/UM?distance=150</a></p>
<p>Notice that the flowline goes downstream of the gage because the NLDI is referenced to whole NHDPlus catchments, not to precise network locations.</p>
<h3>Get Linked Data from Navigation</h3>
<p>Now that we have a <code>{featureSource}</code> = <code>nwissite</code>, a <code>{featureID}</code> = <code>USGS-082795001</code>, the <strong>navigate</strong> operation on the feature, and the <code>{navigationMode}</code> = <code>UM</code> with <code>{distance}</code> = <code>150</code>km, we can use the <a href="https://cida.usgs.gov/nldi/swagger-ui.html#!/linked-data-controller/getFeaturesUsingGET">getFeatures</a> request to discover features from any <code>{featureSource}</code> which, in the context of a getFeatures request, is called a <code>{dataSource}</code>. Setting the <code>{dataSource}</code> = <code>nwissite</code>, we can see if there are any active NWIS streamgages 150km upstream on the main stem with a request that looks like:
<a href="https://cida.usgs.gov/nldi/nwissite/USGS-08279500/navigate/UM/nwissite?distance=150">https://cida.usgs.gov/nldi/nwissite/USGS-08279500/navigate/UM/nwissite?distance=150</a>
Note that we could enter <code>wqp</code> in place of <code>nwissite</code> after <code>UM</code> here to get <a href="https://www.waterqualitydata.us/">water quality portal</a> sites instead of NWIS sites. An example of this is shown later in this post.</p>
<p>Note: Click the black NWIS gage points to see a pop up and link!</p>
<h3>Get the Upstream Basin Boundary</h3>
<p>So far, we’ve covered four parameters of the NLDI Web API. The two base parameters, <code>{featureSource}</code> and <code>{featureID}</code>, and two that apply to the <strong>navigate</strong> option, <code>{navigationMode}</code> and <code>{distance}</code>. In addition to the <strong>navigate</strong> option, the NLDI offers a <strong>basin</strong> option for any <code>{featureSource}</code>/<code>{featureID}</code>. The <a href="https://cida.usgs.gov/nldi/swagger-ui.html#!/characteristics-controller/getBasinUsingGET">getBasin</a> operation doesn’t require any additional parameters, so a request to get the basin for our stream gage looks like:
<a href="https://cida.usgs.gov/nldi/nwissite/USGS-08279500/basin">https://cida.usgs.gov/nldi/nwissite/USGS-08279500/basin</a>.</p>
<h3>NLDI API Summary</h3>
<p>There are a few other options available from the NLDI that are not covered here. One, that is coming soon, will make catchment (local incremental NHDPlus catchment) and basin (upstream accumulation) landscape characteristics available. This functionality and data is available but is preliminary and subject to change.</p>
<p>Bringing together all the operations summarized above, we can get:<br>
1) The NWIS site:<br><a href="https://cida.usgs.gov/nldi/nwissite/USGS-08279500">https://cida.usgs.gov/nldi/nwissite/USGS-08279500</a><br>
2) The basin upstream of the site:<br><a href="https://cida.usgs.gov/nldi/nwissite/USGS-08279500/basin">https://cida.usgs.gov/nldi/nwissite/USGS-08279500/basin</a><br>
3) All upstream with tributaries flowlines:<br><a href="https://cida.usgs.gov/nldi/nwissite/USGS-08279500/navigate/UT">https://cida.usgs.gov/nldi/nwissite/USGS-08279500/navigate/UT</a><br>
4) The upstream mainstem flowlines:<br><a href="https://cida.usgs.gov/nldi/nwissite/USGS-08279500/navigate/UM">https://cida.usgs.gov/nldi/nwissite/USGS-08279500/navigate/UM</a><br>
5) The downstream mainstem flowlines:<br><a href="https://cida.usgs.gov/nldi/nwissite/USGS-08279500/navigate/DM">https://cida.usgs.gov/nldi/nwissite/USGS-08279500/navigate/DM</a><br>
6) The water quality observation sites in upstream catchments:<br><a href="https://cida.usgs.gov/nldi/nwissite/USGS-08279500/navigate/UT/wqp">https://cida.usgs.gov/nldi/nwissite/USGS-08279500/navigate/UT/wqp</a><br>
7) The water quality observations in downstream catchments:<br><a href="https://cida.usgs.gov/nldi/nwissite/USGS-08279500/navigate/DM/wqp">https://cida.usgs.gov/nldi/nwissite/USGS-08279500/navigate/DM/wqp</a></p>
<p>For <a href="http://qgis.org/en/site/">QGIS</a> users, you can use the NLDI URLs directly in the “Add Vector Layer” dialogue. The following two screenshots were rendered by loading the data into QGIS, turning on a base map with the OpenLayers Plugin, and applying a little styling to the NLDI layers. No local files needed!</p>
<p></p>
<p><br>
Screenshots of NLDI data loaded into QGIS.</p>
<h2>Using the NLDI in R.</h2>
<p>Starting from the <a href="https://owi.usgs.gov/blog/basemaps/">recent blog post</a> showing how to use National Map basemaps with leaflet in R, we can map some data retrieved from the NLDI in R. In the code below, the leaflet object <code>map</code> created in the National Map basemap blog post was wrapped up into the <code>get_base_map()</code> function called in the code shown below.</p>
<pre><code>GetURL &lt;- function(service, host = &quot;basemap.nationalmap.gov&quot;) {
  sprintf(&quot;https://%s/arcgis/services/%s/MapServer/WmsServer&quot;, host, service)
}

get_base_map &lt;- function(options = leaflet::leafletOptions()) {
  map &lt;- leaflet::leaflet(options = options)
  grp &lt;- c(&quot;USGS Topo&quot;, &quot;USGS Imagery Only&quot;, &quot;USGS Imagery Topo&quot;,
           &quot;USGS Shaded Relief&quot;, &quot;Hydrography&quot;)
  att &lt;- paste0(&quot;&lt;a href='https://www.usgs.gov/'>&quot;,
                &quot;U.S. Geological Survey&lt;/a> | &quot;,
                &quot;&lt;a href='https://www.usgs.gov/laws/policies_notices.html'>&quot;,
                &quot;Policies&lt;/a>&quot;)
  map &lt;- leaflet::addWMSTiles(map, GetURL(&quot;USGSTopo&quot;),
                              group = grp[1], attribution = att, layers = &quot;0&quot;)
  map &lt;- leaflet::addWMSTiles(map, GetURL(&quot;USGSImageryOnly&quot;),
                              group = grp[2], attribution = att, layers = &quot;0&quot;)
  map &lt;- leaflet::addWMSTiles(map, GetURL(&quot;USGSImageryTopo&quot;),
                              group = grp[3], attribution = att, layers = &quot;0&quot;)
  map &lt;- leaflet::addWMSTiles(map, GetURL(&quot;USGSShadedReliefOnly&quot;),
                              group = grp[4], attribution = att, layers = &quot;0&quot;)
  opt &lt;- leaflet::WMSTileOptions(format = &quot;image/png&quot;, transparent = TRUE)
  map &lt;- leaflet::addWMSTiles(map, GetURL(&quot;USGSHydroCached&quot;),
                              group = grp[5], options = opt, layers = &quot;0&quot;)
  map &lt;- leaflet::hideGroup(map, grp[5])
  opt &lt;- leaflet::layersControlOptions(collapsed = FALSE)
  map &lt;- leaflet::addLayersControl(map, baseGroups = grp[1:4],
                                   overlayGroups = grp[5], options = opt)
}
</code></pre>
<p>First, we get all our URLs into a list and use <strong>readOGR</strong> from the <a href="https://cran.r-project.org/web/packages/rgdal/index.html">rgdal</a> package to download and read all the data into spatial data types. The end of this code block creates html for popup text with a web link tag that we’ll use later.</p>
<pre><code>nldiURLs &lt;- list(site_data = &quot;https://cida.usgs.gov/nldi/nwissite/USGS-08279500&quot;,
             basin_boundary = &quot;https://cida.usgs.gov/nldi/nwissite/USGS-08279500/basin&quot;,
             UT = &quot;https://cida.usgs.gov/nldi/nwissite/USGS-08279500/navigate/UT&quot;,
             UM = &quot;https://cida.usgs.gov/nldi/nwissite/USGS-08279500/navigate/UM&quot;,
             DM = &quot;https://cida.usgs.gov/nldi/nwissite/USGS-08279500/navigate/DM&quot;,
             UTwqp = &quot;https://cida.usgs.gov/nldi/nwissite/USGS-08279500/navigate/UT/wqp&quot;,
             DMwqp = &quot;https://cida.usgs.gov/nldi/nwissite/USGS-08279500/navigate/DM/wqp&quot;)

nldi_data &lt;- list()

for(n in names(nldiURLs)) {
  nldi_data[n] &lt;- rgdal::readOGR(dsn = nldiURLs[n][[1]], layer = &quot;OGRGeoJSON&quot;, verbose = FALSE)
  print(paste(n, &quot;is of class&quot;, class(nldi_data[n][[1]])[1], &quot;and has&quot;, length(nldi_data[n][[1]]), &quot;features&quot;))
}
</code></pre>
<pre><code>## [1] &quot;site_data is of class SpatialPointsDataFrame and has 1 features&quot;
## [1] &quot;basin_boundary is of class SpatialPolygonsDataFrame and has 1 features&quot;
## [1] &quot;UT is of class SpatialLinesDataFrame and has 3371 features&quot;
## [1] &quot;UM is of class SpatialLinesDataFrame and has 184 features&quot;
## [1] &quot;DM is of class SpatialLinesDataFrame and has 1367 features&quot;
## [1] &quot;UTwqp is of class SpatialPointsDataFrame and has 1908 features&quot;
## [1] &quot;DMwqp is of class SpatialPointsDataFrame and has 2756 features&quot;
</code></pre>
<pre><code>UTwqp_html &lt;- paste('&lt;a href=&quot;',
                      nldi_data$UTwqp@data$uri,
                      '&quot;  target=&quot;_blank&quot;>',
                      nldi_data$UTwqp@data$name,
                      '&lt;/a>')

DMwqp_html &lt;- paste('&lt;a href=&quot;',
                      nldi_data$DMwqp@data$uri,
                      '&quot;  target=&quot;_blank&quot;>',
                      nldi_data$DMwqp@data$name,
                      '&lt;/a>')
</code></pre>
<p>Now that we have all our data, we can use leaflet functions to add the data to a map. First, let’s map just the upstream data. Note that the order we add them determines the order the layers are drawn. You can zoom in on the map shown and click the water quality sites to get a popup containing a link to the site’s landing page.</p>
<pre><code>map &lt;- get_base_map() # the function described above.

map &lt;- leaflet::addPolygons(map, 
                            data=nldi_data$basin_boundary, 
                            color = &quot;black&quot;, 
                            fill = FALSE, 
                            weight = 1,
                            opacity = 1)

map &lt;- leaflet::addPolylines(map, 
                             data = nldi_data$UT,
                             color = &quot;blue&quot;,
                             weight = 1,
                             opacity = 1)

map &lt;- leaflet::addPolylines(map,
                             data = nldi_data$UM, 
                             color = &quot;blue&quot;, 
                             weight = 3, 
                             opacity = 0.5)

map &lt;- leaflet::addCircleMarkers(map = map,
                                 data = nldi_data$UTwqp,
                                 radius = 1,
                                 color = &quot;black&quot;,
                                 opacity = .5,
                                 fill = FALSE, 
                                 popup = UTwqp_html)

map &lt;- leaflet::addCircleMarkers(map, 
                                 data = nldi_data$site_data, 
                                 radius = 5, 
                                 color = &quot;red&quot;)
</code></pre>
<p>To complete the picture, we can add the downstream main stem and water quality sites. Now we have an interactive map of all the upstream tributaries, water quality sites, basin boundary, the entire main stem, and water quality sites downstream.</p>
<pre><code>map &lt;- leaflet::addPolylines(map,
                             data = nldi_data$DM, 
                             color = &quot;blue&quot;, 
                             weight = 3, 
                             opacity = 0.5)
map &lt;- leaflet::addCircleMarkers(map = map,
                                 data = nldi_data$DMwqp,
                                 radius = 1,
                                 color = &quot;black&quot;,
                                 opacity = .5,
                                 fill = FALSE, 
                                 popup = DMwqp_html)
</code></pre>
<p>This final map illustrates a very important detail about the NLDI if you zoom in on the downstream main stem. Notice that the sites are not all <strong>on</strong> the main stem flowpath. When the system indexes data sources that aren’t already indexed to particular reachcodes and measures along those reaches, it links sites (points) by looking at what local catchment polygon the site is in. This means that sites found through navigation may not be <strong>on</strong> the main flowpath of a catchment. In the future, we hope to improve the system such that it would know if indexed data are <strong>on</strong> or <strong>off</strong> the main flowpath of a catchment, but for now users need to be aware of this limitation.</p>
<h3>Using the NLDI to discover linked observations data.</h3>
<p>The two sources of linked data shown above, <code>nwissite</code> and <code>wqp</code>, are both queryable from <a href="https://owi.usgs.gov/blog/tags/dataretrieval/">the dataRetrieval package.</a> The “siteNumber” input of the dataRetrieval functions that start with “readNWIS” can be found by removing “USGS-” from the “identifier” attribute of features found using <code>nwissite</code> as the <code>{dataSource}</code> input. The following code shows the NLDI identifiers and how to use them with the dataRetrieval function <strong>readNWISdv</strong>.</p>
<pre><code>nwis_ids &lt;- as.character(nwis_gages@data$identifier)
print(paste(&quot;The NLDI ID for:&quot;, nwis_gages@data$name, &quot;is&quot;, nwis_ids))
</code></pre>
<pre><code>## [1] &quot;The NLDI ID for: RIO GRANDE NEAR LOBATOS, CO is USGS-08251500&quot;                      
## [2] &quot;The NLDI ID for: RIO GRANDE NEAR CERRO, NM is USGS-08263500&quot;                        
## [3] &quot;The NLDI ID for: RIO GRANDE BLW TAOS JUNCTION BRIDGE NEAR TAOS, NM is USGS-08276500&quot;
## [4] &quot;The NLDI ID for: RIO GRANDE AT EMBUDO, NM is USGS-08279500&quot;
</code></pre>
<pre><code>nwis_ids &lt;- gsub(pattern = &quot;USGS-&quot;, replacement = &quot;&quot;, nwis_ids)
print(paste(nwis_gages@data$name, &quot;has id&quot;, nwis_ids))
</code></pre>
<pre><code>## [1] &quot;RIO GRANDE NEAR LOBATOS, CO has id 08251500&quot;                      
## [2] &quot;RIO GRANDE NEAR CERRO, NM has id 08263500&quot;                        
## [3] &quot;RIO GRANDE BLW TAOS JUNCTION BRIDGE NEAR TAOS, NM has id 08276500&quot;
## [4] &quot;RIO GRANDE AT EMBUDO, NM has id 08279500&quot;
</code></pre>
<pre><code># Now we can use these IDs with dataRetrieval.
dv_data &lt;- dataRetrieval::readNWISdv(siteNumber = nwis_ids[1], parameterCd = '00060')
plot(dv_data$Date, dv_data$X_00060_00003, 
     main = paste(&quot;Daily Streamflow for&quot;, nwis_gages@data$name[1]), xlab = &quot;&quot;, ylab = &quot;Daily Streamflow (CFS)&quot;)
</code></pre>
<p></p>
<p>Similarly, we can use identifiers returned using <code>wqp</code> as the <code>{dataSource}</code> with the <strong>readWQPqw</strong> function. In this case, the identifiers can be used without modification as shown below. Note that the NLDI query for downstream mainstem found 2756 sites and upstream tributaries found 1908 sites. The query below gets data from just one! The NLDI is used as a spatial pre-filter in the <a href="https://www.waterqualitydata.us/portal/">Water Quality Portal user interface</a>, which has a rich set of filter options in addition to network navigation.</p>
<pre><code>wqp_site &lt;- list(names = as.character(nldi_data$DMwqp@data$name), 
                 ids = as.character(nldi_data$DMwqp@data$identifier))
print(paste(wqp_site$names[1:10], &quot;has id&quot;, wqp_site$ids[1:10]))
</code></pre>
<pre><code>##  [1] &quot;Unm Resaca nr Hidalgo, TX has id USGS-260708098164501&quot;                    
##  [2] &quot;Rio Grande at Talley Cpgd, BBNP, TX has id USGS-285858103110000&quot;          
##  [3] &quot;Rio Grande at Boquillas Crsg, BBNP, TX has id USGS-291119102564400&quot;       
##  [4] &quot;Lk Amistad Site AMS nr Del Rio, TX has id USGS-292816101061801&quot;           
##  [5] &quot;Rio Grande at Soldado Ck, TX (2011 Gain-Loss) has id USGS-294616101394200&quot;
##  [6] &quot;JL-49-13-823 has id USGS-314516106251401&quot;                                 
##  [7] &quot;JL-49-13-945 has id USGS-314607106244701&quot;                                 
##  [8] &quot;JL-49-14-415 has id USGS-314930106221201&quot;                                 
##  [9] &quot;JL-49-05-630 has id USGS-315659106241101&quot;                                 
## [10] &quot;JL-49-04-106 has id USGS-315733106364501&quot;
</code></pre>
<pre><code>wqp_data &lt;- dataRetrieval::readWQPqw(siteNumbers = wqp_site$ids[1:10], parameterCd = &quot;&quot;)
print(paste0(&quot;Got &quot;, ncol(wqp_data), &quot; samples beween &quot;, min(wqp_data$ActivityStartDate), &quot; and &quot;, max(wqp_data$ActivityStartDate), &quot; for characteristics: &quot;, paste(unique(wqp_data$CharacteristicName), collapse = &quot;, &quot;)))
</code></pre>
<pre><code>## [1] &quot;Got 65 samples beween 1975-06-02 and 2014-05-21 for characteristics: Oxygen, Hydrogen ion, Temperature, water, Barometric pressure, Specific conductance, pH, Depth, Hexachlorocyclopentadiene, Isophorone, Nitrobenzene, 1,2-Dichloropropane, Isopropyl acetate, HCFC-22, HFC-152a, CFC-114, HCFC-123, 1-Methoxy-4-(2-propenyl)benzene, 1,3-Butadiene, Ethylene glycol monoethyl ether acetate, 2-Propen-1-ol, .alpha.-Terpineol, Butyraldehyde, trans-Crotonaldehyde, Stream flow, instantaneous, Hardness, Ca, Mg, Hardness, non-carbonate, Sodium adsorption ratio [(Na)/(sq root of 1/2 Ca + Mg)], Sodium, percent total cations, Total dissolved solids, Ammonia and ammonium, Carbonate, Acetonitrile, Methyl acetate, 1-Butanol, tert-Butanol, Pentanal, 2-Nitropropane, 4-Methyl-2-pentanol, HCFC-21, 5-Methyl-2-hexanone, Isobutyl acetate, 1-Octanol, 1,2,3,4-Tetrahydronaphthalene, 2,6-Dimethyl-4-heptanone, 1,2,3-Trichloropropane, Chloropicrin, Ethylene dibromide, Methyl tert-butyl ether, N-Nitrosodiethylamine, Bicarbonate, Nitrite, Inorganic nitrogen (nitrate and nitrite), Orthophosphate, Calcium, Magnesium, Sodium, Potassium, Chloride, Sulfate, Fluoride, Silica, Arsenic, Boron, Iron, Strontium, Vanadium, Lithium, 1,1-Dichloropropanone, Butane, Dimethoxymethane, 1,4-Dioxane, 1,3-Dioxolane, Ethyl acetate, Hexane, Pentane, 1,2-Dibromo-3-chloropropane, 1-Chloro-1,1-difluoroethane, 1-Bromo-3-chloropropane-d6, Tetrahydrofuran-d8, Carbon dioxide, Trihalomethanes, 2,4-D-d3, Selenium, Alkalinity, total, Bromide, Deuterium, Oxygen-18, Diuron-d6, cis-Permethrin-13C6, Butachlor ESA, Dimethachlor sulfonic acid, Tebuconazole-d6, Thiobencarb-d10, Metolachlor-d6, Nicosulfuron-d6, Hexazinone-d6, Linuron-d6, Malathion-D10, Diflubenzuron-d4, Carbendazim-d4, Carbofuran-D3, Deethylatrazine-d6, Diazinon-D10, Acetochlor-d11, Alachlor-d13, Carbaryl-d7, 3-Phenoxybenzoic acid-13C6, 3-Phenoxybenzoic acid, Chlorimuron-ethyl, Alachlor ESA, 1rs Cis-Permethrin, Triclopyr, Triallate, Tribufos, Transpermethrin, Terbufos sulfone, Terbufos sulfoxide, Terbufos oxon sulfoxide, Terbufos oxygen analog sulfone, Terbufos, Terbufos oxon, Terbacil, Tebuthiuron TP 109, Tebuthiuron, Tebupirimfos oxon, Tebufenozide, Phostebupirim, 2,3,3-Trichloro-2-propene-1-sulfonic acid (sodium salt), Sulfosulfuron ethyl sulfone, Sulfosulfuron, Sulfentrazone, Sulfometuron methyl, sec-Alachlor oxanilic acid, Siduron, sec-Acetochlor oxanilic acid, Pyriproxyfen, Pyridaben, Propoxur, Pymetrozine, Propazine, Propargite, Profenofos, Phthalazinone, Phorate sulfoxide, Phorate sulfone, Phorate oxygen analog sulfone, Phorate oxon sulfoxide, Phorate, Phorate O.A., Oxamyl oxime, Paraoxon, Oryzalin, Oxamyl, Orthosulfamuron, 2-Hydroxy-4-isopropylamino-6-amino-s-triazine, 2-Hydroxyatrazine, Omethoate, O-Ethyl S-methyl S-propyl phosphorodithioate, O-Ethyl S-propyl phosphorothioate, 2-Hydroxy-6-ethylamino-4-amino-s-triazine, Novaluron, Naled, Metribuzin DK, Metolachlor ESA, Metribuzin, Metolachlor OA, Methyl paraoxon, Metolachlor hydroxy morpholinone, Methomyl oxime, Methoxyfenozide, MCPA, Methamidophos, Methomyl, Linuron, Lactofen, Isoxaflutole, Hydroxysimazine, Imazamox, Indoxacarb, Hydroxyphthalazinone, Hydroxytebuthiuron, Hydroxymetolachlor, Hydroxyfluometuron, Hydroxy didemethyl fluometuron, Hydroxy monodemethyl fluometuron, Hydroxydiazinon, Hydroxyalachlor, Hydroxyacetochlor, Fluometuron, 2-(1-Hydroxyethyl)-6-methylaniline, Fipronil amide, Fipronil sulfonate, Flubendiamide, Fentin, Fenamiphos sulfoxide, Fenbutatin-oxide, Fenamiphos Sulfone, Fenamiphos, O-Ethyl O-methyl S-propyl phosphorothioate, Etoxazole, Ethoprop, 2-[(2-Ethyl-6-methylphenyl)amino]-1-propanol, Disulfoton sulfone, Oxydisulfoton, Demethyl fluometuron, Disulfoton oxon sulfone, Demeton-S, Disulfoton oxon sulfoxide, Dimethenamid ESA, Dimethenamid sulfinylacetic acid, Dimethenamid oxanilic acid, Diflufenzopyr, Benzenepropanenitrile, .alpha.-(cyclopropylcarbonyl)- 2-(methylsulfonyl)-.beta.- oxo-4-(trifluoromethyl)-, Dimethenamid, Diflubenzuron, Didemethyl tebuthiuron, Dichlorvos, Dicrotophos, Dicamba, Metribuzin DA, Metribuzin DADK, Desulfinylfipronil amide, Desmethylnorflurazon, Deisopropyl prometryn, Deiodo flubendiamide, Dechlorometolachlor, Dechlorofipronil, cis-Cyhalothric acid, Chlorthal-Monomethyl, 2-Chloro-4-isopropylamino-6-amino-s-triazine, Desisopropyl atrazine, Chlorosulfonamide acid, Carboxy molinate, Carbendazim, 2-Chloro-4,6-diamino-s-triazine, Bromoxynil, Butralin, Bentazon, Bromacil, Ametryn, Asulam, Aldicarb sulfoxide, Aldicarb sulfone, Alachlor sulfinylacetic acid, Aldicarb, Alachlor oxanilic acid, Acetochlor sulfinylacetic acid, 2-Chloro-2',6'-diethylacetanilide, Acetochlor OA, Acetochlor ESA, 2-Chloro-N-(2-ethyl-6-methylphenyl)acetamide, Acetochlor, 4-Hydroxy molinate, Acephate, 4-Chlorobenzylmethyl sulfoxide, 4-(Hydroxymethyl) pendimethalin, 2-Isopropyl-6-methyl-4-pyrimidinol, 3-Hydroxycarbofuran, 2-Aminobenzimidazole, 2-Amino-N-isopropylbenzamide, Metalaxyl, 1H-1,2,4-Triazole, 2,4-D, Imidacloprid, Malaoxon, 4-Hydroxychlorothalonil, 1-(3,4-dichlorophenyl)-3-methyl urea, Diazoxon, Chlorpyrifos O.A., 3,4-Dichlorophenylurea, Azinphos-methyl oxygen analog, Prometon, Pronamide, Kresoxim-methyl, Norflurazon, Disulfoton, Famoxadone, Trifloxystrobin, Tetraconazole, Chlorsulfuron, Flumetsulam, Halosulfuron-methyl, Imazaquin, Imazethapyr, Nicosulfuron, Prosulfuron, Alachlor, Azinphos-methyl, Bifenthrin, Butylate, Carbaryl, Carbofuran, Chlorpyrifos, Diazinon, S-Ethyl dipropylthiocarbamate, Fonofos, Hexazinone, Malathion, Methidathion, Metolachlor, Molinate, Oxyfluorfen, Pendimethalin, Piperonyl butoxide, Prometryn, Simazine, Thiobencarb, Azoxystrobin, Cyanazine, Dimethoate, Diuron, Fipronil, 1H-Pyrazole-3-carbonitrile, 5-amino-1-[2,6-dichloro-4-(trifluoromethyl)phenyl]-4-(trifluoromethyl)-, 5-Amino-1-[2,6-dichloro-4-(trifluoromethyl)phenyl]-4-[(trifluoromethyl)thio]pyrazole-3-carbonitrile, Fipronil Sulfone, Metconazole, Myclobutanil, Propanil, Propiconazole, Pyraclostrobin, Tebuconazole, Terbuthylazine, Barium, Beryllium, Cadmium, Chromium, Cobalt, Copper, Lead, Manganese, Thallium, Molybdenum, Nickel, Silver, Zinc, Antimony, Aluminum, Gross-Uranium, Perchlorate, Nitrate, Organic Nitrogen, Radium-224, Radium-226, Lead-210, Polonium-210, Arsenate, Monomethylarsonate, Cacodylic acid, Alpha particle, Beta particle, Arsenite, Radium-228, Temperature, air, deg C, Turbidity, Dichlorobromomethane, Carbon tetrachloride, 1,2-Dichloroethane, Tribromomethane, Chlorodibromomethane, Chloroform, Toluene, Benzene, Chlorobenzene, Ethylbenzene, Methyl bromide, Methylene chloride, Tetrachloroethene, 1,1-Dichloroethane, 1,1-Dichloroethylene, 1,1,1-Trichloroethane, 1,1,2-Trichloroethane, o-Dichlorobenzene, Nitrogen, mixed forms (NH3), (NH4), organic, (NO2) and (NO3), Kjeldahl nitrogen, Phosphorus, trans-1,2-Dichloroethylene, 1,2,4-Trichlorobenzene, p-Dichlorobenzene, Naphthalene, trans-1,3-Dichloropropene, cis-1,3-Dichloropropene, Vinyl chloride, Trichloroethene (TCE), Isobutyl alcohol-d6, Carbon disulfide, cis-1,2-Dichloroethylene, Styrene, o-Xylene, 1,2,4-Trimethylbenzene, n-Propylbenzene, Halon 1011, sec-Butylbenzene, 1,1,1,2-Tetrachloroethane, m,p-Xylene, 1,2-Dichloroethane-d4, Chloromethane, p-Bromofluorobenzene, Toluene-d8, Organic carbon, Radon-222, Escherichia coli, Total Coliform, Enterococcus, Coliphage, Male Specific (F+) all Groups, cis-Androsterone-2,2,3,4,4-d5, Carbon-14, Carbon, isotope of mass 13, Tritium&quot;
</code></pre>
<h2>Summary</h2>
<p>In this blog post, we summarized the NLDI’s Web API through links to the system’s <a href="https://cida.usgs.gov/nldi/swagger-ui.html">Swagger</a> documentation. The primary API parameters, <code>{featureSource}</code> and <code>{featureID}</code>, were described. Two functions that operate with any <code>{featureID}</code>, <strong>navigation</strong> (and it’s optional <code>{distance}</code> parameter) and <strong>basin</strong> were demonstrated. The the <strong>navigation</strong> function’s <code>{dataSource}</code> parameter, which can be any <code>{featureSource}</code>, was shown by retrieving NWIS (<code>nwissite</code>) and WQP (<code>wqp</code>) sites upstream and downstream of an NWIS site.</p>
<p>Building on the <a href="https://owi.usgs.gov/blog/basemaps/">recent blog post</a> showing how to use National Map basemaps with leaflet in R, downloading, parsing, and mapping NLDI data in R was demonstrated. This basic demonstration can be extended by using different NLDI inputs and there are many operations that are supported by the spatial data formats returned by the <a href="https://www.rdocumentation.org/packages/rgdal/versions/1.2-5/topics/readOGR">rgdal packge function <strong>readOGR</strong>.</a></p>
<p>The post finishes by showing how to use sites found with the NLDI to download data from the National Water Information System and Water Quality portal. The potential for extending this use of the NLDI is vast. As more feature/data sources are indexed and the system evolves, the NLDI should serve as a major new discovery service for many sources of observed and modeled data.</p>
<p>The NLDI is an exciting new service that is being implemented in an incremental and agile development process. Given that, the API will expand and new versions of the API may have somewhat different design. The intention is to keep the Web API described here the same, only changing it by introducing a version identifier as an API parameter. If you found this useful and plan on using the NLDI as a dependency in a project of application, we would greatly appreciate hearing about your use case and can answer any questions you have while implementing your application.</p>
<p>Please email <a href="mailto:dblodgett@usgs.gov">dblodgett@usgs.gov</a> with questions and feedback.</p>