Closed ldecicco-USGS closed 1 year ago
url <- "https://nwis.waterdata.usgs.gov/nwis/peak?state_cd=pa&group_key=county_cd&sitefile_output_format=html_table&column_name=agency_cd&column_name=site_no&column_name=station_nm&set_logscale_y=1&format=rdb&date_format=YYYY-MM-DD&rdb_compression=value&hn2_compression=file&list_of_search_criteria=state_cd"
x <- importRDB1(url)
Generally, the readNWISdata
function requires the user to be pretty savvy with understanding how to call their data. However, when we can make their lives a little easier we try.
The question here is for the peak service: https://nwis.waterdata.usgs.gov/nwis/peak
So, right now, for the user to get peak data for a single state, they need to do this:
x2 <- readNWISdata(state_cd = "PA",
list_of_search_criteria="state_cd",
service = "peak")
If you don't add that list_of_search_criteria="state_cd",
, you get the whole country.
What we could do is add another check here. Somewhere in readNWISdots
we could add:
if (service == "peak" & "state_cd" %in% names(values)){
values["list_of_search_criteria"] <- "state_cd"
}
Then we'd want to add an example to the readNWISdata
helpfile that looks like this:
pa_peaks <- readNWISdata(state_cd = "PA",
service = "peak")
We should then also add that as a test in the testthat folder.
So, things to do:
I would expect this to work:
But, you need this instead:
We should check state, county, and HUC queries and make sure the peak requests act similar to the other services.