header_tag.html

Skip to contents

Imports daily data from NWIS web service. This function gets the data from here: https://waterservices.usgs.gov/

Usage

readNWISDaily(siteNumber, parameterCd = "00060", startDate = "",
  endDate = "", verbose = TRUE, convert = TRUE, adjust = TRUE,
  fill = FALSE, maxgap = 21, fill_type = "interpolation")

Arguments

siteNumber

character USGS site number. This is usually an 8 digit number.

parameterCd

character USGS parameter code. This is usually an 5 digit number.

startDate

character starting date for data retrieval in the form YYYY-MM-DD.

endDate

character ending date for data retrieval in the form YYYY-MM-DD.

verbose

logical specifying whether or not to display messages.

convert

logical Option to include a conversion from cfs to cms (35.314667). The default is TRUE which is appropriate for using NWIS data in the EGRET package. Set this to FALSE to not include the conversion. If the parameter code is not 00060 (NWIS discharge), there is no conversion applied.

adjust

logical specifying whether or not to add a constant to zero values to allow log transformation. Defaults to TRUE.

fill

logical specifying whether to fill NA values by linear interpolation. Defaults to FALSE.

maxgap

Maximum number of NA days allowed for interpolating gaps. Default is 21. Only used if fill is set to TRUE.

fill_type

character to define what process to fill missing data. Options are "interpolation", "spline", or "tsSmooth". "interpolation" is linear interpolation from the `zoo::na.approx`. "spline" is a spline fit using `zoo::na.spline`. "tsSmooth" uses `stats::tsSmooth` which is fixed-interval smoothing on time series. "tsStruct" uses a structural time series models. "log_interp" is linear interpolation in the log space.

Value

A data frame 'Daily' with the following columns:

NameTypeDescription
DateDateDate
QnumericDischarge in m^3/s
JulianintegerNumber of days since Jan. 1, 1850
MonthintegerMonth of the year [1-12]
DayintegerDay of the year [1-366]
DecYearnumericDecimal year
MonthSeqintegerNumber of months since January 1, 1850
QualifiercharacterQualifying code
iintegerIndex of days, starting with 1
LogQnumericNatural logarithm of Q
Q7numeric7 day running average of Q
Q30numeric30 day running average of Q

Examples

if (FALSE) { # interactive()
# \donttest{

Daily <- readNWISDaily('01594440','00060',
                       '2004-01-01', '2024-03-31')
DailySuspSediment <- readNWISDaily('01594440','80154',
                                   '1985-01-01', '1985-03-31',
                                   convert = FALSE)
# }
}