Description Usage Arguments Value Note Author(s) References See Also Examples
Retrieve U.S. Geological Survey (USGS) daily mean-streamflow values for a streamgage identification number. This function is a wrapper on dataRetrieval::
readNWISdv()
and thus provides an abstraction layer to the dataRetrieval package but this wrapper has powerful features suitable for data-mining scale study of daily values. The dvget
function adds some additional information for purpose of the akqdecay package. The function creates the canonical daily-mean streamflow table (an R data.frame
) to be picked up in turn by the akqdecay
function of this package. The function fill_dvenv
is a wrapper that can be used to fill an R environment
with the output of the akqdecay
function.
1 2 3 4 5 |
siteNumber |
USGS streamgage identification number and nomenclature matches that of the dataRetrieval package. Multiple site numbers can be provided because the underlying |
sdate |
Start date (default is earliest) and nomenclature matches that of the dataRetrieval package with string format of “YYYY-MM-DD” for year (YYYY), month (MM), and day (DD) respectively padded by zeros as needed; |
edate |
Ending date (default is earliest) and nomenclature matches that of the dataRetrieval package with string format of “YYYY-MM-DD” for year (YYYY), month (MM), and day (DD) respectively padded by zeros as needed; |
flowlo |
Optional lower streamflow threshold on which to convert to |
flowhi |
Optional upper streamflow threshold on which to convert to |
date2s |
An optional start date of record (greater than and equal to) in the same format as |
date2e |
An optional ending date of record (less than and equal to) in the same format as |
ignore.working |
The USGS identifies at least “Approved” ( |
ignore.provisional |
The USGS identifies at least “Approved” ( |
silent |
Suppress informative calls to |
drsilent |
The argument though converted to “silent” that is passed to |
drget |
If set, the retrieval from |
pCode |
Parameter code (default is discharge [streamflow]) and nomenclature almost matches that of the dataRetrieval package; |
sCode |
Statistic code (default is daily mean) and nomenclature almost matches that of the dataRetrieval package |
message |
An optional string that if populated will trigger a |
... |
Additional arguments to pass to function |
An R data.frame
is returned with these expected columns. Some streamgages can have multiple discharges descriptors typed as daily values. Only the Flow
column is handled by akqdecay.
agency_cd |
The agency code for the data; |
site_no |
The streamgage identification number; |
Date |
The date, note that the capitalization is from the dataRetrieval package, elsewhere in akqdecay this will become lower case; |
Flow |
The streamflow in cubic feet per second, note that the capitalization is from the dataRetrieval package, elsewhere in akqdecay this will become lower case or an alternative name for streamflow; |
Flow_cd |
A coding system for the streamflow ( |
site |
A character representation of the |
year |
The calendar year of the date; |
decade |
The decade of the daily value. The decade is assign by taking the year and the trailing digit has been stripped and replaced with zero. This is not a technique in which a “decade” is centered on an even step of 10—meaning, say that 1996–2005 is not the “2000 decade” but simply 01/01/2000–12/31/2009 is the “2000 decade;” |
wyear |
The water year; and |
month |
The month. |
For the greater purposes of the akqdecay package, the arguments pCode
and sCode
for their defaults are expected to be left untouched. The capitalization inconsistency in the returned R data.frame
is left intact as it is consistent with the operation of the dataRetrieval::
renameNWISColumns()
function that is called internally. Lastly, at least one streamgage (07040000 in 2015 [as for Nov. 2017 testing]) has been found in massive-scale testing that has -999999 for a daily flow. Such values are converted to NA
.
W.H. Asquith
Hirsch, R.M., and De Cicco, L.A., 2015, User guide to Exploration and Graphics for RivEr Trends (EGRET) and dataRetrieval: R packages for hydrologic data (version 2.0, February 2015): U.S. Geological Survey Techniques and Methods book 4, chap. A10, 93 p., http://doi.org/10.3133/tm4A10.
akqdecay
, fill_dvenv
, gsid2str
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | # USGS 14362000 Applegate River near Copper, Oregon
Copper <- dvget("14362000", sdate="1940-01-01", edate="1940-01-31")
print(Copper) # An inspection of the retrieved daily values. #
## Not run:
dv <- dvget("07040000") # 2019-05-05 testing. This is how we can have a look
# at the streamgage. The Internet indicates gage discontinued in 2011 but
# -999999 start showing up in May 2016---Is this related to the AQ database change?
attributes(dv)$akqdecay
# [1] "at least one -999999 discharge: first=2016-05-05 and last=2019-05-04"
# Test on June 29, 2020 shows this message or issue of -999999 appears gone.
## End(Not run)
## Not run:
# This is a big time sink so treated as a "dontrun."
# Get all of the sites in Alabama that have discharge (00060) and then
# just work on those that seem to have record after June 1st, 2019.
AL <- dataRetrieval::whatNWISsites(stateCd="AL", parameterCd="00060")
AL <- AL[AL$site_tp_cd == "ST",]; # isolate just the streamgages, then remove
AL <- AL[as.numeric(AL$site_no) <= 100000000000000,] # lat/long based site numbers
sites <- AL$site_no
DV <- new.env(); n <- length(sites); i <- 0
for(site in sites) {
i <- i + 1
message("working on site ",site, " ",i,"(",n,")")
dv <- NULL
try(dv <- dvget(site, sdate="2019-06-01", ignore.provisional=FALSE))
if(is.null(dv)) next; if(length(dv$site_no) == 0) next
assign(site, dv, envir=DV)
}#
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.