Learn R Programming

dataRetrieval (version 2.0.1)

readNWISqw: Raw Data Import for USGS NWIS QW Data

Description

Imports data from NWIS web service. This function gets the data from here: http://nwis.waterdata.usgs.gov/nwis/qwdata A list of parameter codes can be found here: http://nwis.waterdata.usgs.gov/nwis/pmcodes/ A list of statistic codes can be found here: http://nwis.waterdata.usgs.gov/nwis/help/?read_file=stat&format=table

Usage

readNWISqw(siteNumbers, parameterCd, startDate = "", endDate = "",
  expanded = TRUE, reshape = FALSE, tz = "")

Arguments

siteNumbers
character of USGS site numbers. This is usually an 8 digit number
parameterCd
character of USGS parameter code(s). This is usually an 5 digit number.
startDate
character starting date for data retrieval in the form YYYY-MM-DD. Default is "" which indicates retrieval for the earliest possible record.
endDate
character ending date for data retrieval in the form YYYY-MM-DD. Default is "" which indicates retrieval for the latest possible record.
expanded
logical defaults to TRUE. If TRUE, retrieves additional information. Expanded data includes remark_cd (remark code), result_va (result value), val_qual_tx (result value qualifier code), meth_cd (method code), dqi_cd (data-quali
reshape
logical, reshape the data. If TRUE, then return a wide data frame with all water-quality in a single row for each sample. If FALSE (default), then return a long data frame with each water-quality result in a single row.
tz
character to set timezone attribute of datetime. Default is an empty quote, which converts the datetimes to UTC (properly accounting for daylight savings times based on the data's provided tz_cd column). Possible values to provide are "America/New_York"

Value

  • A data frame with the following columns: lll{ Name Type Description agency_cd character The NWIS code for the agency reporting the data site_no character The USGS site number datetime POSIXct The date and time of the value converted to UTC (if asDateTime = TRUE), character or raw character string (if asDateTime = FALSE) tz_cd character The time zone code for datetime code character Any codes that qualify the corresponding value value numeric The numeric value for the parameter } There are also several useful attributes attached to the data frame: lll{ Name Type Description url character The url used to generate the data queryTime POSIXct The time the data was returned comment character Header comments from the RDB file siteInfo data.frame A data frame containing information on the requested sites variableInfo data.frame A data frame containing information on the requested parameters }

See Also

readWQPdata, whatWQPsites, readWQPqw, constructNWISURL

Examples

Run this code
siteNumbers <- c('04024430','04024000')
startDate <- '2010-01-01'
endDate <- ''
parameterCd <- c('34247','30234','32104','34220')
rawNWISqwData <- readNWISqw(siteNumbers,parameterCd,startDate,endDate)
rawNWISqwDataReshaped <- readNWISqw(siteNumbers,parameterCd,
          startDate,endDate,reshape=TRUE)

Run the code above in your browser using DataLab