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

Problem retrieving discrete groundwater levels after switching to the GitHub version of dataRetrieval #719

Closed tlroot closed 1 month ago

tlroot commented 1 month ago

What is your question? I ran into an issue with retrieving discrete groundwater levels after installing dataRertrieval from GitHub rather than CRAN. I am wondering if this is a bug or if I need to use different script with the newer version of dataRetrieval.

To Reproduce

    periodicGWLevelData <- readNWISdata(sites = "282341081040101", 
                                    startDT = "1900-01-01", 
                                    endDT = "2024-07-26", 
                                    parameterCd = "62611",  
                                    service = "gwlevels") 

Expected behavior When run using dataRetrieval downloaded from Cran on 7/26/24, the above code results in a data frame with 477 observations and 18 variables. When run using dataRetrieval downloaded from GitHub on 7/26/24, the above code returns a data frame with 1 column and hundreds of rows of .html code (see screenshot below). It is not a site-specific problem - the script cycles through 492 groundwater sites and the issue occurs with all of them.

Screenshots image

Session Info R-4.4.0patched RStudio 2024.04.2 Build 764



**Additional context**
Add any other context about the problem here.
ldecicco-USGS commented 1 month ago

Yeah, there's a change in underlying services coming to the groundwater services. The github version of dataRetrieval should now use:

    periodicGWLevelData <- readNWISdata(site_no = "282341081040101", 
                                    begin_date = "1900-01-01", 
                                    end_date = "2024-07-26", 
                                    service = "gwlevels") 

The service we need to switch to doesn't have a specific parameter code query.

If you are always asking for a site or list of sites, you can also use:

periodicGWLevelData <- readNWISgwl("282341081040101",
                                   parameterCd = "62611")

We baked in a parameter code filter to the function.

I'll think about adding some simple logic to this PR: https://github.com/DOI-USGS/dataRetrieval/pull/717 to get those arguments to be more backwards compatible (specifically site, startDT, endDT).