-
Laura A DeCicco authoredLaura A DeCicco authored
dataRetrieval.Rnw 27.19 KiB
%\VignetteIndexEntry{Introduction to the dataRetrieval package}
%\VignetteDepends{}
%\VignetteSuggests{}
%\VignetteImports{}
%\VignettePackage{}
\documentclass[a4paper,11pt]{article}
\usepackage{amsmath}
\usepackage{times}
\usepackage{hyperref}
\usepackage[numbers, round]{natbib}
\usepackage[american]{babel}
\usepackage{authblk}
\renewcommand\Affilfont{\itshape\small}
\usepackage{Sweave}
\renewcommand{\topfraction}{0.85}
\renewcommand{\textfraction}{0.1}
\usepackage{graphicx}
\textwidth=6.2in
\textheight=8.5in
\parskip=.3cm
\oddsidemargin=.1in
\evensidemargin=.1in
\headheight=-.3in
%------------------------------------------------------------
% newcommand
%------------------------------------------------------------
\newcommand{\scscst}{\scriptscriptstyle}
\newcommand{\scst}{\scriptstyle}
\newcommand{\Robject}[1]{{\texttt{#1}}}
\newcommand{\Rfunction}[1]{{\texttt{#1}}}
\newcommand{\Rclass}[1]{\textit{#1}}
\newcommand{\Rpackage}[1]{\textit{#1}}
\newcommand{\Rexpression}[1]{\texttt{#1}}
\newcommand{\Rmethod}[1]{{\texttt{#1}}}
\newcommand{\Rfunarg}[1]{{\texttt{#1}}}
\begin{document}
\SweaveOpts{concordance=TRUE}
%------------------------------------------------------------
\title{Introduction to the dataRetrieval package}
%------------------------------------------------------------
\author[1]{Laura De Cicco}
\author[1]{Robert Hirsch}
\affil[1]{United States Geological Survey}
\SweaveOpts{highlight=TRUE, tidy=TRUE, keep.space=TRUE, keep.blank.space=FALSE, keep.comment=TRUE, keep.source=TRUE}
\maketitle
\tableofcontents
%------------------------------------------------------------
\section{Introduction to dataRetrieval}
%------------------------------------------------------------
The dataRetrieval package was created to simplify the process of getting hydrologic data in the R enviornment. It has been specifically designed to work seamlessly with the EGRET package: Exploration and Graphics for RivEr Trends (EGRET). See: \url{https://github.com/USGS-R/EGRET/wiki} for information on EGRET.
There is a plethora of hydrological data available on the web. This package is designed specifically to load United States Geological Survey (USGS) hydrologic data to the R enviornment. This includes daily values, real-time (unit values), site information, and water quality sample data.
For information on getting started in R, downloading and installing the package, see Appendix 1: Getting Started.
%------------------------------------------------------------
\section{USGS Web Retrieval Examples}
%------------------------------------------------------------
In this section, we will run through 5 examples, documenting how to get raw data from the web. This includes historical daily values, real-time current values, water quality data, site information, and measured parameter information. We will use the Choptank River near Greensboro, MD as an example. The site-ID for this gage station is 01491000. Daily discharge measurements are available as far back as 1948. Additionally, forms of nitrate have been measured dating back to 1964. The functions/examples in this section are for raw data retrieval. This may or may not be the easiest data to work with. In the next section, we will use functions that retrieve and process the data in a dataframe that may prove more friendly for R analysis.
%------------------------------------------------------------
\subsection{USGS Web Retrieval Introduction}
%------------------------------------------------------------
The United States Geological Survey organizes their hydrological data in fairly standard structure. Gage stations are located throughout the United States, each station has a unique ID. Often (but not always), these ID's are 8 digits. The first step to finding data is discoving this 8-digit ID. One potential tool for discovering data is Environmental Data Discovery and Transformation (EnDDaT): \url{http://cida.usgs.gov/enddat/}. Follow the example in the User's Guide to learn how to discover USGS stations and available data from any location in the United States. Essentially, you can create a Project Location on the map, set a bounding box (in miles), then search for USGS Time Series and USGS Water Quality Data. Locations, ID's, available data, and available time periods will load on the map and appropriate tabs.
Once the site-ID is known, the next required input for USGS data retrievals is the 'parameter code'. This is a 5-digit code that specifies what measured paramater is being requested. A complete list of possible USGS parameter codes can be found at \href{http://nwis.waterdata.usgs.gov/usa/nwis/pmcodes?radio_pm_search=param_group&pm_group=All+--+include+all+parameter+groups&pm_search=&casrn_search=&srsname_search=&format=html_table&show=parameter_group_nm&show=parameter_nm&show=casrn&show=srsname&show=parameter_units}{nwis.waterdata.usgs.gov}. Not every station will measure all parameters. The following is a list of commonly measured parameters:
<<openLibrary, echo=FALSE>>=
library(xtable)
options(continue=" ")
options(SweaveHooks=list(fig=function()
par(mar=c(4.1,4.1,1.1,4.1),oma=c(0,0,0,0))))
@
@
<<label=tableParameterCodes, echo=FALSE,results=tex>>=
pCode <- c('00060', '00065', '00010','00045','00400')
shortName <- c("Discharge [cfs]","Gage height [ft]","Temperature [C]", "Precipitation [in]", "pH")
data.df <- data.frame(pCode, shortName, stringsAsFactors=FALSE)
data.table <- xtable(data.df,
caption="Commonly found USGS Parameter Codes")
print(data.table,
caption.placement="top")
@
For real-time data, the parameter code and site ID will suffice. The USGS stores historical data as daily values however. The statistical process used to store the daily data is the final requirement for daily value retrievals. A 5-digit 'stat code' specifies the requested processing. A complete list of possible USGS stat codes can be found here:
\url{http://nwis.waterdata.usgs.gov/nwis/help/?read_file=stat&format=table}
The most common stat codes are:
<<label=tableStatCodes, echo=FALSE,results=tex>>=
StatCode <- c('00001', '00002', '00003','00008')
shortName <- c("Maximum","Minimum","Mean", "Median")
data.df <- data.frame(StatCode, shortName, stringsAsFactors=FALSE)
data.table <- xtable(data.df,
caption="Commonly found USGS Stat Codes")
print(data.table,
caption.placement="top")
@
%------------------------------------------------------------
\subsection{USGS Site Information Retrievals}
%------------------------------------------------------------
To obtain all of the available site information, use the getSiteFileData function:
<<label=getSite, echo=TRUE>>=
library(dataRetrieval)
# Site ID for Choptank River near Greensboro, MD
siteNumber <- "01491000"
ChoptankInfo <- getSiteFileData(siteNumber)
@
<<label=tableSiteInfo, echo=FALSE,results=tex>>=
infoDF <- data.frame(ColumnNames=names(ChoptankInfo[1:11]),ColumnNames=names(ChoptankInfo[12:22]),
ColumnNames=names(ChoptankInfo[23:33]),ColumnNames=names(c(ChoptankInfo[34:43],"")))
data.table <- xtable(infoDF,
caption="Column names in ChoptankInfo")
print(data.table, caption.placement="top",floating="FALSE",latex.environments=NULL)
@
\\*
Pulling out a specific example piece of information, in this case station name can be done as follows:
<<siteNames, echo=TRUE>>=
ChoptankInfo$station.nm
@
Site information is obtained from \url{http://waterservices.usgs.gov/rest/Site-Test-Tool.html}
%------------------------------------------------------------
\subsection{USGS Parameter Information Retrievals}
%------------------------------------------------------------
To obtain all of the available information concerning a measured parameter, use the getParameterInfo function:
<<label=getSite, echo=TRUE>>=
# Using defaults:
parameterCd <- "00618"
parameterINFO <- getParameterInfo(parameterCd)
colnames(parameterINFO)
@
Pulling out a specific example piece of information, in this case station name can be done as follows:
<<siteNames, echo=TRUE>>=
parameterINFO$parameter_nm
@
Parameter information is obtained from \url{http://nwis.waterdata.usgs.gov/nwis/pmcodes/}
%------------------------------------------------------------
\subsection{USGS Daily Value Retrievals}
%------------------------------------------------------------
To obtain historic daily records of USGS data, use the retrieveNWISData function. The arguments for this function are siteNumber, parameterCd, startDate, endDate, statCd, and a logical (true/false) interactive. There are 2 default argument: statCd defaults to "00003" and interactive defaults to TRUE. If you want to use the default values, you do not need to list them in the function call. Setting the 'interactive' option to true will walk you through the function. It might make more sense to run large batch collections with the interactive option set to FALSE.
The dates (start and end) need to be in the format "YYYY-MM-DD". Setting the start date to "" will indicate to the program to ask for the earliest date, setting the end date to "" will ask for the latest available date.
<<label=getNWISDaily, echo=TRUE>>=
# Using defaults:
siteNumber <- "01491000"
parameterCd <- "00060" # Discharge in cubic feet per second
startDate <- "" # Will request earliest date
endDate <- "" # Will request latest date
discharge <- retrieveNWISData(siteNumber, parameterCd, startDate, endDate)
@
A dataframe is returned that looks like the following:
<<dischargeData, echo=FALSE>>=
head(discharge)
@
The variable datetime is automatically imported as a Date. Each requested parameter has a value and remark code column. The names of these columns depend on the requested parameter and stat code combinations. USGS remark codes are often "A" (approved for publication) or "P" (provisional data subject to revision). A more complete list of remark codes can be found here:
\url{http://waterdata.usgs.gov/usa/nwis/help?codes_help}
Another example that doesn't use the defaults would be a request for mean and maximum daily temperature and discharge in early 2012:
<<label=getNWIStemperature, echo=TRUE>>=
# Using defaults:
siteNumber <- "01491000"
parameterCd <- "00010,00060" # Temperature and discharge
statCd <- "00001,00003" # Mean and maximum
startDate <- "2012-01-01"
endDate <- "2012-06-30"
temperatureAndFlow <- retrieveNWISData(siteNumber, parameterCd,
startDate, endDate, StatCd=statCd,interactive=FALSE)
@
Daily data is pulled from \url{http://waterservices.usgs.gov/rest/DV-Test-Tool.html}.
An example of plotting the above data (Figure 1):
<<label=getNWIStemperaturePlot, echo=TRUE>>=
with(temperatureAndFlow, plot(
datetime, X01_00010_00003,
xlab="Date",ylab="Temperature [C]"
))
par(new=TRUE)
with(temperatureAndFlow, plot(
datetime, X02_00060_00003,
col="red",type="l",xaxt="n",yaxt="n",xlab="",ylab="",axes=FALSE
))
axis(4,col="red",col.axis="red")
mtext("Discharge [cfs]",side=4,line=3,col="red")
@
\newpage
\begin{figure}
\begin{center}
<<label=fig1, fig=TRUE,echo=FALSE,width=6,height=4>>=
<<getNWIStemperaturePlot>>
@
\end{center}
\caption{Temperature and discharge plot of Choptank River in 2012.}
\end{figure}
There are occasions where NWIS values are not reported as numbers, instead there might be text describing a certain event such as "Ice". Any value that cannot be converted to a number will be reported as NA in this package.
%------------------------------------------------------------
\subsection{USGS Unit Value Retrievals}
%------------------------------------------------------------
We can also get real-time, instantaneous measurements using the retrieveUnitNWISData function:
<<label=getNWISUnit, echo=TRUE>>=
siteNumber <- "01491000" # Site ID for Choptank River near Greensboro, MD
parameterCd <- "00060" # Discharge in cubic feet per second
startDate <- as.character(Sys.Date()-1) # Yesterday
# (or, the day before the dataRetrieval package was built)
endDate <- as.character(Sys.Date()) # Today
# (or, the day the dataRetrieval package was built)
dischargeToday <- retrieveUnitNWISData(siteNumber, parameterCd,
startDate, endDate)
@
Which produces the following dataframe:
<<dischargeData, echo=FALSE>>=
head(dischargeToday)
@
Note that time now becomes important, so the variable datetime is a POSIXct, and the time zone is included in a separate column. Data is pulled from \url{http://waterservices.usgs.gov/rest/IV-Test-Tool.html}. There are occasions where NWIS values are not reported as numbers, instead a common example is "Ice". Any value that cannot be converted to a number will be reported as NA in this package.
A simple plotting example is shown in Figure 2:
<<label=getNWISUnit, echo=TRUE>>=
with(dischargeToday, plot(
datetime, X02_00060,
ylab="Discharge [cfs]",xlab=""
))
@
\newpage
\begin{figure}
\begin{center}
<<label=fig2, fig=TRUE,echo=FALSE,width=6,height=4>>=
<<getNWISUnit>>
@
\end{center}
\caption{Real-time discharge plot of Choptank River.}
\end{figure}
%------------------------------------------------------------
\subsection{USGS Water Quality Retrievals}
%------------------------------------------------------------
Finally, we can use the dataRetrieval package to get water quality data that is available on the water quality data portal: \url{http://www.waterqualitydata.us/}. The raw data us obtained from the function getRawQWData, with the similar input arguments: siteNumber, parameterCd, startDate, endDate, and interactive. The difference is in parameterCd, in this function multiple parameters can be queried using a ";" separator, and setting parameterCd <- "" will return all of the measured observations. The raw data can be overwelming (as will be demonstrated), a simplified version of the data can be obtained using getQWData.
<<label=getQW, echo=TRUE>>=
siteNumber <- "01491000"
# Dissolved Nitrate parameter codes:
parameterCd <- "00618;71851"
startDate <- "1964-06-11"
endDate <- "2012-12-18"
dissolvedNitrate <- getRawQWData(siteNumber, parameterCd,
startDate, endDate)
@
There is a large amount of data returned for each observation. The column names are listed below:
<<label=colNamesQW, echo=FALSE,results=tex>>=
infoDF <- data.frame(ColumnNames=names(dissolvedNitrate[1:31]),ColumnNames=names(dissolvedNitrate[32:62]))
data.table <- xtable(infoDF,
caption="Column names in dissolvedNitrate")
print(data.table, caption.placement="top",floating="FALSE",latex.environments=NULL)
@
\\*
To get a simplified dataframe that contains only datetime, value, and qualifier, use the function getQWData:
<<label=getQWData, echo=TRUE>>=
dissolvedNitrateSimple <- getQWData(siteNumber, parameterCd,
startDate, endDate)
names(dissolvedNitrateSimple)
@
Note that in this dataframe, datatime is imported as Dates (no times are included), and the qualifier is either blank or \verb@"<"@ signifying a censored value.
An example of plotting the above data (Figure 3):
<<label=getQWtemperaturePlot, echo=TRUE>>=
with(dissolvedNitrateSimple, plot(
dateTime, value.00618,
xlab="Date",ylab = paste(parameterINFO$srsname,
"[",parameterINFO$parameter_units,"]")
))
@
\begin{figure}
\begin{center}
<<label=fig3, fig=TRUE,echo=FALSE,width=6,height=4>>=
<<getQWtemperaturePlot>>
@
\end{center}
\caption{Nitrate plot of Choptank River.}
\end{figure}
%------------------------------------------------------------
\section{Polished Data: USGS Web Retrieval Examples}
%------------------------------------------------------------
Rather than using the raw data as retrieved by the web, the dataRetrieval package also includes functions that return the data in a structure that has been designed to work with the EGRET R package (\url{https://github.com/USGS-R/EGRET/wiki}). In general, these dataframes may be much more 'R-friendly' than the raw data, and will contain additional date information that allows for efficient data analysis.
In this section, we use 3 dataRetrieval functions to get sufficient data to perform an EGRET analysis. We will continue analyzing the Choptank River. We will need essentially the same data that was retrieved in the previous section, but we will get the daily discharge values in a dataframe called Daily, the nitrate sample data in a dataframe called Sample, and the data about the station and parameters in a dataframe called INFO. These are the dataframes that were exclusively designed to work with the EGRET R package, however can be very useful for all hydrologic studies.
The funtion to obtain the daily values (discharge in this case) is getDVData. It requires the inputs siteNumber, ParameterCd, StartDate, EndDate, interactive, and convert. Most of these arguments are described in the previous section, however 'convert' is a new argument, it's default is TRUE, and it tells the program to convert the values from cfs to cms. If you don't want this conversion, set convert=FALSE in the function call.
<<firstExample>>=
siteNumber <- "01491000"
parameterCd <- "00631" # Nitrate
startDate <- "1964-01-01"
endDate <- "2013-01-01"
Daily <- getDVData(siteNumber, "00060", startDate, endDate,interactive=FALSE)
summary(Daily)
@
Date is a column with dates stored in an R Date type. Julian is an integer number of days since January 1, 1850. Month and Day are integers from the start of each year. DecYear is the decimal year. MonthSeq is the (integer) number of months since 1850. Qualifier is the code from NWIS as mentioned in the raw data section. i is a count of observations. LogQ is the natural logarithm of Q. The code will shift the discharge values to 0.001 times the mean if there are zero values detected in order to perform the logarithm. Columns Q7 and Q30 are 7 and 30 day running averages.
The function to obtain sample data from the water quality portal is getSampleData. The arguments for this function are also siteNumber, ParameterCd, StartDate, EndDate, interactive. These are the same inputs as getRawQWData or getQWData as described in the previous section.
<<secondExample>>=
Sample <-getSampleData(siteNumber,parameterCd,startDate, endDate,interactive=FALSE)
summary(Sample)
@
The function to obtain "metadata", data about the gage station and measured parameters is getMetaData. This function essentially combines getSiteFileData and getParameterInfo, producing one dataframe called INFO.
<<ThirdExample>>=
INFO <-getMetaData(siteNumber,parameterCd, interactive=FALSE)
@
<<label=colNamesQW, echo=FALSE,results=tex>>=
infoDF <- data.frame(ColumnNames=names(INFO[1:21]),ColumnNames=names(c(INFO[22:41],"")))
data.table <- xtable(infoDF,
caption="Column names in the INFO dataframe")
print(data.table, caption.placement="top",floating="FALSE",latex.environments=NULL)
@
\\*
<<forthExample>>=
Sample <- mergeReport()
head(Sample)
@
The difference between these dataframes, and the dataframes in the previous sections is that ...
\newpage
%------------------------------------------------------------
\section{Retrieving User-Generated Data Files}
%------------------------------------------------------------
Aside from retrieving data from the USGS web services, the dataRetrieval package includes functions to generate the Daily and Sample data frame from local files.
%------------------------------------------------------------
\subsection{getDailyDataFromFile}
%------------------------------------------------------------
getDailyDataFromFile will load a user-supplied text file and convert it to the Daily dataframe. The file should have two columns, the first dates, the second values. The dates should be formatted either mm/dd/yyyy or yyyy-mm-dd. Using a 4-digit year is required. This function has the following inputs: filePath, fileName,hasHeader (TRUE/FALSE), separator, qUnit, and interactive (TRUE/FALSE). filePath is a string that defines the path to your file. This can either be a full path, or path relative to your R working directory. The input fileName is a string that defines the file name (including the extension).
Text files that contain this sort of data require some sort of a separator, for example, a 'csv' file (aka 'comma-separated value') file uses a comma to separate the date and value column. A tab delimited file would use a tab ("\verb@\t@") rather than the comma (","). The type of separator you use can be defined in the function call in the 'separator' argument, the default is ",". Another function input is a logical variable: hasHeader. The default is TRUE. If your data does not have column names, set this variable to FALSE.
Finally, qUnit is a numeric input that defines the discharge/flow units. Flow from the NWIS web results are typically given in cubic feet per second (qUnit=1), but the EGRET package requires flow to be given in cubic meters per second (qUnit=2). Other allowed values are 10\verb@^@3 cubic feet per second (qUnit=3) and 10\verb@^@3 cubic meters per second (qUnit=4). If you do not want your data to be converted, use qUnit=2. The default is qUnit=1 (assumes flow is in cubic feet per second).
So, if you have a file called "ChoptankRiverFlow.txt" located in a folder called "RData" on your C drive (this is a Window's example), and the file is structured as follows (tab-separated):
\begin{verbatim}
date Qdaily
10/1/1999 3.029902561
10/2/1999 2.406931941
10/3/1999 2.152080324
10/4/1999 2.152080324
10/5/1999 3.19980364
10/6/1999 2.775050944
...
\end{verbatim}
The call to open this file, convert the flow to cubic meters per second, and populate the Daily data frame would be:
<<openDaily, eval = TRUE>>=
fileName <- "ChoptankRiverFlow.txt"
filePath <- "~/RData/"
Daily <- getDailyDataFromFile(filePath,fileName,separator="\t",interactive=FALSE)
head(Daily)
@
%------------------------------------------------------------
\subsection{getSampleDataFromFile}
%------------------------------------------------------------
Similarly to the previous section, getSampleDataFromFile will import a user-generated file and populate the Sample dataframe. The difference between sample data and flow data is that the code requires a third column that contains a remark code, either blank or \verb@"<"@, which will tell the program that the data was 'left-censored' (or, below the detection limit of the sensor). Therefore, the data is required to be in the form: date, remark, value. If multiple constituents are going to be used, the format can be date, remark\_A, value\_A, remark\_b, value\_b, etc... An example of a comma-delimited file would be:
\begin{verbatim}
cdate;remarkCode;Nitrate
10/7/1999;;1.4
11/4/1999;<;0.99
12/3/1999;;1.42
1/4/2000;;1.59
2/3/2000;;1.54
...
\end{verbatim}
The call to open this file, and populate the Sample dataframe would be:
<<openSample, eval = TRUE>>=
fileName <- "ChoptankRiverNitrate.csv"
filePath <- "~/RData/"
Sample <- getSampleDataFromFile(filePath,fileName,separator=";",interactive=FALSE)
head(Sample)
@
\newpage
%------------------------------------------------------------
\section{Appendix 1: Getting Started}
%------------------------------------------------------------
This section describes the options for downloading and installing the dataRetrieval package.
%------------------------------------------------------------
\subsection{New to R?}
%------------------------------------------------------------
If you are new to R, you will need to first install the latest version of R, which can be found here: \url{http://www.r-project.org/}.
There are many options for running and editing R code, one nice enviornment to learn R is RStudio. RStudio can be downloaded here: \url{http://rstudio.org/}. Once R and RStudio are installed, the dataRetrieval package needs to be installed as described in the next section.
%------------------------------------------------------------
\subsection{R User: Installing dataRetrieval from downloaded binary}
%------------------------------------------------------------
The latest dataRetrieval package build is available for download at \url{https://github.com/USGS-R/dataRetrieval/blob/master/dataRetrieval_1.2.1.tar.gz}. If the package's tar.gz file is saved in R's working directory, then the following command will fully install the package:
<<installFromWD,eval = FALSE>>=
install.packages("dataRetrieval_1.2.1.tar.gz",
repos=NULL, type="source")
@
If the downloaded file is stored in an alternative location, include the path in the install command. A Windows example looks like this (notice the direction of the slashes, they are in the opposite direction that Windows normally creates paths):
<<installFromFile,eval = FALSE>>=
install.packages(
"C:/RPackages/Statistics/dataRetrieval_1.2.1.tar.gz",
repos=NULL, type="source")
@
A Mac example looks like this:
<<maxExample,eval = FALSE>>=
install.packages(
"/Users/userA/RPackages/Statistic/dataRetrieval_1.2.1.tar.gz",
repos=NULL, type="source")
@
It is a good idea to re-start the R enviornment after installing the package, especially if installing an updated version (that is, restart RStudio). Some users have found it necessary to delete the previous version's package folder before installing newer version of dataRetrieval. If you are experiencing issues after updating a package, trying deleting the package folder - the default location for Windows is something like this: C:/Users/userA/Documents/R/win-library/2.15/dataRetrieval, and the default for a Mac: /Users/userA/Library/R/2.15/library/dataRetrieval. Then, re-install the package using the directions above. Moving to CRAN should solve this problem.
After installing the package, you need to open the library each time you re-start R. This is done with the simple command:
<<openLibraryTest, eval=FALSE>>=
library(dataRetrieval)
@
Using RStudio, you could alternatively click on the checkbox for dataRetrieval in the Packages window.
%------------------------------------------------------------
\subsection{R Developers: Installing dataRetrieval from gitHub}
%------------------------------------------------------------
Alternatively, R-developers can install the latest version of dataRetrieval directly from gitHub using the devtools package. devtools is available on CRAN. Simpley type the following commands into R to install the latest version of dataRetrieval available on gitHub. Rtools (for Windows) and appropriate \LaTeX\ tools are required.
<<gitInstal,eval = FALSE>>=
library(devtools)
install_github("dataRetrieval", "USGS-R")
@
To then open the library, simply type:
<<openLibrary, eval=FALSE>>=
library(dataRetrieval)
@
\newpage
%------------------------------------------------------------
% BIBLIO
%------------------------------------------------------------
\begin{thebibliography}{10}
\bibitem{HirschI}
Helsel, D.R. and R. M. Hirsch, 2002. Statistical Methods in Water Resources Techniques of Water Resources Investigations, Book 4, chapter A3. U.S. Geological Survey. 522 pages. \url{http://pubs.usgs.gov/twri/twri4a3/}
\bibitem{HirschII}
Hirsch, R. M., Moyer, D. L. and Archfield, S. A. (2010), Weighted Regressions on Time, Discharge, and Season (WRTDS), with an Application to Chesapeake Bay River Inputs. JAWRA Journal of the American Water Resources Association, 46: 857-880. doi: 10.1111/j.1752-1688.2010.00482.x \url{http://onlinelibrary.wiley.com/doi/10.1111/j.1752-1688.2010.00482.x/full}
\bibitem{HirschIII}
Sprague, L. A., Hirsch, R. M., and Aulenbach, B. T. (2011), Nitrate in the Mississippi River and Its Tributaries, 1980 to 2008: Are We Making Progress? Environmental Science \& Technology, 45 (17): 7209-7216. doi: 10.1021/es201221s \url{http://pubs.acs.org/doi/abs/10.1021/es201221s}
\end{thebibliography}
\end{document}
\end{document}