Learn R Programming

⚠️There's a newer version (2.7.11) of this package.Take me there.

dataRetrieval

Retrieval functions for USGS and EPA hydrologic and water quality data.

Linux:

Windows:

##Package Installation To install the dataRetrieval package, you must be using R 3.0 or greater and run the following command:

install.packages("dataRetrieval")

To get inter-CRAN release updates, use the command:

install.packages("dataRetrieval",repos="http://owi.usgs.gov/R")

Function Overview

Web service retrieval functions:

FunctionInputsDescription
readNWISdata..., serviceNWIS data using user-specified queries
readNWISdvCommon 3, parameterCd, statCdNWIS daily data with Common query
readNWISqwCommon 3, parameterCd, expanded,reshape,tzNWIS water quality data with Common query
readNWISuvCommon 3, parameterCd,tzNWIS instantaneous data with Common query
readNWISpCodeparameterCdNWIS parameter code information
readNWISgwlCommon 3NWIS groundwater level data with Common query
readNWISpeakCommon 3,asDateTimeNWIS peak flow data with Common query
readNWISmeasCommon 3, tzNWIS surface-water measurement data with Common query
readNWISratingsiteNumber, typeNWIS rating table for an active USGS streamgage
readNWISsitesiteNumberNWIS site information
whatNWISsites...NWIS site search using user-specified queries
whatNWISdatasiteNumber, serviceNWIS data availability, including period of record and count
readWQPdata...WQP data using user-specified queries
readWQPqwCommon 3, parameterCd**,tzWQP data with Common 3 query and either parameter code or characteristic name
whatWQPsites...WQP site search using user-specified queries
  • Common 3 = siteNumber, startDate, endDate
  • ... = user-defined arguments.

**parameterCd in WQP function can be either USGS parameter codes, or EPA characteristic names

##Reporting bugs

Please consider reporting bugs and asking questions on the Issues page:

https://github.com/USGS-R/dataRetrieval/issues

##Subscribe Please email questions, comments, and feedback to: egret_comments@usgs.gov

Additionally, to subscribe to an email list concerning updates to these R packages, please send a request to egret_comments@usgs.gov.

##Latest Version Updates

###dataRetrieval 2.2.0

  • Changed the output of tz_cd (in all *NWIS functions) to the timezone that is reported in the data frame. Before this version, it was the time zone reported by NWIS. This was confusing however since the dateTime columns default to UTC.
  • Minor bug fixes
  • Help file updates
  • Improved query options in readNWISdata and readWQPdata functions.

##Disclaimer This software is in the public domain because it contains materials that originally came from the U.S. Geological Survey, an agency of the United States Department of Interior. For more information, see the official USGS copyright policy

Although this software program has been used by the U.S. Geological Survey (USGS), no warranty, expressed or implied, is made by the USGS or the U.S. Government as to the accuracy and functioning of the program and related program material nor shall the fact of distribution constitute any such warranty, and no responsibility is assumed by the USGS in connection therewith.

This software is provided "AS IS."

CRAN statistics:

Research software impact:

Copy Link

Version

Install

install.packages('dataRetrieval')

Monthly Downloads

3,021

Version

2.5.1

License

CC0

Issues

Pull Requests

Stars

Forks

Maintainer

Laura DeCicco

Last Published

February 18th, 2022

Functions in dataRetrieval (2.5.1)

importRDB1

Function to return data from the NWIS RDB 1.0 format
constructWQPURL

Construct WQP url for data retrieval
checkWQPdates

Date Check for Water Quality Portal
importWQP

Basic Water Quality Portal Data parser
constructNWISURL

Construct NWIS url for data retrieval
getWebServiceData

Function to return data from web services
importWaterML2

Function to return data from the WaterML2 data
dataRetrieval-package

Retrieval functions for USGS and EPA data
importWaterML1

Function to return data from the NWISWeb WaterML1.1 service
countyCd

US County Code Lookup Table
readNWISmeas

Surface-water measurement data retrieval from USGS (NWIS)
readNWISpCode

USGS Parameter Data Retrieval
readNWISsite

USGS Site File Data Retrieval
readNWISpeak

Peak flow data from USGS (NWIS)
readNWISdv

Daily Value USGS NWIS Data Retrieval
readNWISuv

Instantaneous value data retrieval from USGS (NWIS)
readNWISdata

General Data Import from NWIS
pCodeToName

Data to convert USGS parameter code to characteristic names
readNWISgwl

Groundwater level measurements retrieval from USGS (NWIS)
readNWISqw

Raw Data Import for USGS NWIS QW Data
renameNWISColumns

renameColumns
stateCd

US State Code Lookup Table
whatNWISdata

USGS data availability
readWQPdata

General Data Import from Water Quality Portal
whatNWISsites

Site Data Import from NWIS
setAccess

Set data endpoint
whatWQPsites

Site Data Import from Water Quality Portal
stateCdLookup

State code look up
xmlcontent

drop in replacement for httr switching to xml2 from XML
readWQPqw

Raw Data Import for Water Quality Portal
zeroPad

Pad string with leading zeros
readNWISrating

Rating table for an active USGS streamgage retrieval