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
259 stars 84 forks source link

Skip sites that do not have available data instead of failing #573

Closed jessnicwelch closed 3 years ago

jessnicwelch commented 3 years ago

Describe a feature you would like to see added When I provide a list of lists containing a vector of sites (sites were collected using navigate_nldi {nhdplusTools}) to the whatNWISdata command, some sites do not have available data (i.e., it returns "HTTP Status 404 - No sites found matching this request, server=[sdas01]").

Instead of failing, I would like the command to "skip" the missing sites and continue to the next list of sites. This way, I do not have to manually remove sites that do not have available data and I save a lot of time.

To Reproduce (Simplified) steps to reproduce the behavior:

gageTmp <- whatNWISdata(sites = c("02181600","02181650","02182150","02182200","02182500","02183130","02183280","02183610"),
    parameterCd = c("00010","00060"),
    service = "dv")

Returns Request failed [404]. Retrying in 1.4 seconds... Request failed [404]. Retrying in 3.4 seconds... For: https://waterservices.usgs.gov/nwis/site/?seriesCatalogOutput=true&sites=02181600,02181650,02182150,02182200,02182500,02183130,02183280,02183610&parameterCd=00010,00060&format=rdb

Screenshot of error URL

Example of site with no available data: https://waterdata.usgs.gov/nwis/inventory/?site_no=02181600&agency_cd=USGS

Additional context

I am happy to provide more code if necessary.