uses the Network Linked Data Index to retrieve and estimated network location for the given point. If not within a grid cell of a flowline, will use a raindrop trace service to find the nearest downslope flowline location.

get_nldi_index(location)

Arguments

location

numeric WGS84 lon/lat pair (X, Y)

Examples

# \donttest{
index <- get_nldi_index(c(-89.276, 42.988))
#> https://labs-beta.waterdata.usgs.gov/api/nldi/linked-data/hydrolocation?coords=POINT(-89.276%2042.988)

if(inherits(index, "sf")) {

plot_nhdplus(bbox = sf::st_bbox(sf::st_buffer(index[1,], units::set_units(1000, "m"))))
plot(sf::st_geometry(sf::st_transform(index, 3857)), add = TRUE)

}
#> Spherical geometry (s2) switched off
#> https://api.water.usgs.gov/geoserver/wmadata/ows 
#> <?xml version="1.0" encoding="UTF-8"?>
#> <wfs:GetFeature xmlns:wfs="http://www.opengis.net/wfs" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:gml="http://www.opengis.net/gml" service="WFS" version="1.1.0" outputFormat="application/json" xsi:schemaLocation="http://www.opengis.net/wfs                         http://schemas.opengis.net/wfs/1.1.0/wfs.xsd">
#>   <wfs:Query xmlns:feature="https://api.water.usgs.gov/wmadata" typeName="feature:nhdflowline_network" srsName="EPSG:4269">
#>     <ogc:Filter xmlns:ogc="http://www.opengis.net/ogc">
#>       <ogc:And>
#>         <ogc:BBOX>
#>           <ogc:PropertyName>the_geom</ogc:PropertyName>
#>           <gml:Envelope srsName="urn:x-ogc:def:crs:EPSG:4326">
#>             <gml:lowerCorner>42.9746981418854 -89.2919956215314</gml:lowerCorner>
#>             <gml:upperCorner>42.9929396814273 -89.2672111467203</gml:upperCorner>
#>           </gml:Envelope>
#>         </ogc:BBOX>
#>       </ogc:And>
#>     </ogc:Filter>
#>   </wfs:Query>
#> </wfs:GetFeature>
#> although coordinates are longitude/latitude, st_intersects assumes that they
#> are planar
#> Spherical geometry (s2) switched on
#> Zoom set to: 12

# }