Learn R Programming

dataRetrieval (version 2.5.1)

readNWISdata: General Data Import from NWIS

Description

Returns data from the NWIS web service. Arguments to the function should be based on http://waterservices.usgs.gov service calls. See examples below for ideas of constructing queries.

Usage

readNWISdata(service = "dv", ...)

Arguments

service
character. Possible values are "iv" (for instantaneous), "dv" (for daily values), "gwlevels" (for groundwater levels), "site" (for site service), "qw" (water-quality), and "measurement". Note: "qw" and "measurement" calls go to: http://nwis.waterdata.usgs.gov/usa/nwis for data requests, and use different call requests schemes.

Value

A data frame with the following columns:
Name Type
Description agency
character The NWIS code for the agency reporting the data
site character
The USGS site number dateTime
POSIXct The date and time (if applicable) of the measurement, converted to UTC for unit value data. R only allows one time zone attribute per column. For unit data spanning a time zone change, converting the data to UTC solves this problem. For daily data, the time zone attribute is the time zone of the first returned measurement.
tz_cd character
The time zone code for dateTime column 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, importRDB1

Examples

Run this code
## Not run: 
# # Examples not run for time considerations
# dataTemp <- readNWISdata(stateCd="OH",parameterCd="00010", service="dv")
# instFlow <- readNWISdata(sites="05114000", service="iv", 
#                    parameterCd="00060", 
#                    startDate="2014-05-01T00:00Z",endDate="2014-05-01T12:00Z")
#                                                    
# instFlowCDT <- readNWISdata(sites="05114000", service="iv", 
#                    parameterCd="00060", 
#                    startDate="2014-05-01T00:00",endDate="2014-05-01T12:00",
#                    tz="America/Chicago")
# 
# #Empty:
# multiSite <- readNWISdata(sites=c("04025000","04072150"), service="iv", 
#                            parameterCd="00010")
# #Not empty:
# multiSite <- readNWISdata(sites=c("04025500","040263491"), 
#                            service="iv", parameterCd="00060")
# bBoxEx <- readNWISdata(bBox=c(-83,36.5,-81,38.5), parameterCd="00010")
# 
# startDate <- as.Date("2013-10-01")
# endDate <- as.Date("2014-09-30")
# waterYear <- readNWISdata(bBox=c(-83,36.5,-81,38.5), parameterCd="00010", 
#                   service="dv", startDate=startDate, endDate=endDate)
# siteInfo <- readNWISdata(stateCd="WI", parameterCd="00010",
#                   hasDataTypeCd="iv", service="site")
# qwData <- readNWISdata(bBox=c(-82.5,41.52,-81,41),startDate=as.Date("2000-01-01"),
#                   drain_area_va_min=50, qw_count_nu=50,qw_attributes="expanded",
#                   qw_sample_wide="wide",list_of_search_criteria=c("lat_long_bounding_box",
#                   "drain_area_va","obs_count_nu"),service="qw")
# temp <- readNWISdata(bBox=c(-83,36.5,-81,38.5), parameterCd="00010", service="site", 
#                    seriesCatalogOutput=TRUE)
# wiGWL <- readNWISdata(stateCd="WI",service="gwlevels")
# meas <- readNWISdata(state_cd="WI",service="measurements",format="rdb_expanded")
# ## End(Not run)

Run the code above in your browser using DataLab