Learn R Programming

dataRetrieval (version 2.5.1)

readNWISuv: Instantaneous value data retrieval from USGS (NWIS)

Description

Imports data from NWIS web service. This function gets the data from here: http://waterservices.usgs.gov/ 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. More information on the web service can be found here: http://waterservices.usgs.gov/rest/IV-Service.html.

Usage

readNWISuv(siteNumbers, parameterCd, startDate = "", endDate = "", tz = "")

Arguments

siteNumbers
character USGS site number (or multiple sites). 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. Default is "" which indicates retrieval for the earliest possible record. Simple date arguments are specified in local time. See more information here: http://waterservices.usgs.gov/rest/IV-Service.html#Specifying.
endDate
character ending date for data retrieval in the form YYYY-MM-DD. Default is "" which indicates retrieval for the latest possible record. Simple date arguments are specified in local time. See more information here: http://waterservices.usgs.gov/rest/IV-Service.html#Specifying.
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","America/Chicago", "America/Denver","America/Los_Angeles", "America/Anchorage","America/Honolulu","America/Jamaica","America/Managua","America/Phoenix", and "America/Metlakatla"

Value

A data frame with the following columns:
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
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 Name
Note that code and value are repeated for the parameters requested. The names are of the form: X_D_P_S, where X is literal, D is an option description of the parameter, P is the parameter code, and S is the statistic code (if applicable).There are also several useful attributes attached to the data frame:
Name Type
Description url
character The url used to generate the data
siteInfo data.frame
A data frame containing information on the requested sites variableInfo
data.frame A data frame containing information on the requested parameters
statisticInfo data.frame
A data frame containing information on the requested statistics on the data queryTime
POSIXct The time the data was returned

See Also

renameNWISColumns, importWaterML1

Examples

Run this code
siteNumber <- '05114000'
parameterCd <- '00060'
startDate <- "2014-10-10"
endDate <- "2014-10-10"
## Not run: 
# rawData <- readNWISuv(siteNumber,parameterCd,startDate,endDate)
# 
# timeZoneChange <- readNWISuv(c('04024430','04024000'),parameterCd,
#          "2013-11-03","2013-11-03")
#  
# centralTime <- readNWISuv(siteNumber,parameterCd,
#                            "2014-10-10T12:00", "2014-10-10T23:59",
#                            tz="America/Chicago")
# 
# # Adding 'Z' to the time indicates to the web service to call the data with UTC time:
# GMTdata <- readNWISuv(siteNumber,parameterCd,
#                            "2014-10-10T00:00Z", "2014-10-10T23:59Z")
# ## End(Not run)

Run the code above in your browser using DataLab