DOI-USGS / dataRetrieval

This R package is designed to obtain USGS or EPA water quality sample data, streamflow data, and metadata directly from web services.
https://doi-usgs.github.io/dataRetrieval/
Other
256 stars 85 forks source link

findNLDI return error #631

Closed Toby-Stegman-cbec closed 1 year ago

Toby-Stegman-cbec commented 1 year ago

Greetings,

I have not been able to get the findNLDI tool to work. It looks super powerful and I am really excited about its potential.

Any suggestions? I just installed the latest version of the package and have been getting this error with all sorts of attempts to use the tool. Am I missing a step before this, or is it a bug?

Thanks,

library(dplyr)         # Data frame manipulation
library(ggplot2)       # Plotting
library(patchwork)     # Arranging plots
library(dataRetrieval) # The star of the show!

#remotes::install_github("USGS-R/dataRetrieval")

##############################################################################################################################

get_nldi_sources()

features <- findNLDI(comid = 101)

features <- findNLDI(nwis = "01491000",
                     nav = "UT",
                     find = c('basin', 'wqp'))

The Error

> features <- findNLDI(nwis = "01491000",
+                      nav = "UT",
+                      find = c('basin', 'wqp'))
Error in request(method = y$method %||% x$method, url = y$url %||% x$url, : is.character(url) is not TRUE
Request failed [ERROR]. Retrying in 1 seconds...
Error in request(method = y$method %||% x$method, url = y$url %||% x$url, : is.character(url) is not TRUE
Request failed [ERROR]. Retrying in 1 seconds...
Error in request(method = y$method %||% x$method, url = y$url %||% x$url,  : 
  is.character(url) is not TRUE
dblodgett-usgs commented 1 year ago

Hi @cbec -- when I try this, I get the result in the reprex below. Can you make sure all your dataRetrieval dependencies are up to date? I'm not really sure what would be causing the error you are seeing. That request function isn't something I'm familiar with.

library(dataRetrieval)

get_nldi_sources()
#>            source                                     sourceName
#> 1        ca_gages                 Streamgage catalog for CA SB19
#> 2  geoconnex-demo              geoconnex contribution demo sites
#> 3      gfv11_pois USGS Geospatial Fabric V1.1 Points of Interest
#> 4         huc12pp                              HUC12 Pour Points
#> 5        nmwdi-st          New Mexico Water Data Initative Sites
#> 6          nwisgw                         NWIS Groundwater Sites
#> 7        nwissite                       NWIS Surface Water Sites
#> 8        ref_gage                   geoconnex.us reference gages
#> 9           vigil                             Vigil Network Data
#> 10           wade                  Water Data Exchange 2.0 Sites
#> 11            WQP                           Water Quality Portal
#> 12          comid                                  NHDPlus comid
#>                                                               features
#> 1        https://labs.waterdata.usgs.gov/api/nldi/linked-data/ca_gages
#> 2  https://labs.waterdata.usgs.gov/api/nldi/linked-data/geoconnex-demo
#> 3      https://labs.waterdata.usgs.gov/api/nldi/linked-data/gfv11_pois
#> 4         https://labs.waterdata.usgs.gov/api/nldi/linked-data/huc12pp
#> 5        https://labs.waterdata.usgs.gov/api/nldi/linked-data/nmwdi-st
#> 6          https://labs.waterdata.usgs.gov/api/nldi/linked-data/nwisgw
#> 7        https://labs.waterdata.usgs.gov/api/nldi/linked-data/nwissite
#> 8        https://labs.waterdata.usgs.gov/api/nldi/linked-data/ref_gage
#> 9           https://labs.waterdata.usgs.gov/api/nldi/linked-data/vigil
#> 10           https://labs.waterdata.usgs.gov/api/nldi/linked-data/wade
#> 11            https://labs.waterdata.usgs.gov/api/nldi/linked-data/wqp
#> 12          https://labs.waterdata.usgs.gov/api/nldi/linked-data/comid

(features <- findNLDI(comid = 101))
#> Simple feature collection with 1 feature and 3 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 × 4
#>   sourceName    identifier comid                                        geometry
#>   <chr>         <chr>      <chr>                                <LINESTRING [°]>
#> 1 NHDPlus comid 101        101   (-94.64845 31.09915, -94.64803 31.09871, -94.6…

(features <- findNLDI(nwis = "01491000",
                     nav = "UT",
                     find = c('basin', 'wqp')))
#> Warning: No data returned for: https://labs.waterdata.usgs.gov/api/nldi/linked-
#> data/nwissite/USGS-01491000/navigation/UT/WQP?f=json&distance=100
#> $origin
#> Simple feature collection with 1 feature and 8 fields
#> Geometry type: POINT
#> Dimension:     XY
#> Bounding box:  xmin: -75.78581 ymin: 38.99719 xmax: -75.78581 ymax: 38.99719
#> Geodetic CRS:  WGS 84
#> # A tibble: 1 × 9
#>   sourceName               identifier  comid measure reachcode name      X     Y
#>   <chr>                    <chr>       <chr>   <dbl> <chr>     <chr> <dbl> <dbl>
#> 1 NWIS Surface Water Sites USGS-01491… 9407…    4.27 02060005… CHOP… -75.8  39.0
#> # … with 1 more variable: geometry <POINT [°]>
#> 
#> $basin
#> Simple feature collection with 1 feature and 0 fields
#> Geometry type: POLYGON
#> Dimension:     XY
#> Bounding box:  xmin: -75.82904 ymin: 38.98298 xmax: -75.58261 ymax: 39.19027
#> Geodetic CRS:  WGS 84
#> # A tibble: 1 × 1
#>                                                                         geometry
#>                                                                    <POLYGON [°]>
#> 1 ((-75.79434 39.00067, -75.79569 39.01328, -75.80388 39.02363, -75.82105 39.03…

Created on 2022-08-10 by the reprex package (v2.0.1)

Toby-Stegman-cbec commented 1 year ago

Thanks dblodgett-usgs!

I tried reinstalling the package again, and choose to update all packages, again, with the install. This time I noticed my laptop doesn't want to update all the packages for some reason. So, I tried a different computer and got things to work! I think you are right, that it is something with a package dependency that doesn't work.