Skip to content
Snippets Groups Projects
importRDB1.Rd 4.07 KiB
Newer Older
Laura A DeCicco's avatar
Laura A DeCicco committed
% Generated by roxygen2 (4.1.1): do not edit by hand
% Please edit documentation in R/importRDB1.r
Laura A DeCicco's avatar
Laura A DeCicco committed
\name{importRDB1}
\alias{importRDB1}
Laura A DeCicco's avatar
Laura A DeCicco committed
\title{Function to return data from the NWIS RDB 1.0 format}
\usage{
importRDB1(obs_url, asDateTime = FALSE, qw = FALSE, convertType = TRUE,
  tz = "")
Laura A DeCicco's avatar
Laura A DeCicco committed
}
\arguments{
Laura A DeCicco's avatar
Laura A DeCicco committed
\item{obs_url}{character containing the url for the retrieval or a file path to the data file.}
Laura A DeCicco's avatar
Laura A DeCicco committed
\item{asDateTime}{logical, if \code{TRUE} returns date and time as POSIXct, if \code{FALSE}, Date}
Laura A DeCicco's avatar
Laura A DeCicco committed

Laura A DeCicco's avatar
Laura A DeCicco committed
\item{qw}{logical, if \code{TRUE} parses as water quality data (where dates/times are in start and end times)}
Laura A DeCicco's avatar
Laura A DeCicco committed
\item{convertType}{logical, defaults to \code{TRUE}. If \code{TRUE}, the function will convert the data to dates, datetimes,
numerics based on a standard algorithm. If false, everything is returned as a character}
\item{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"}
Laura A DeCicco's avatar
Laura A DeCicco committed
}
\value{
A data frame with the following columns:
\tabular{lll}{
Name \tab Type \tab Description \cr
agency_cd \tab character \tab The NWIS code for the agency reporting the data\cr
site_no \tab character \tab The USGS site number \cr
Laura A DeCicco's avatar
Laura A DeCicco committed
datetime \tab POSIXct \tab The date and time of the value converted to UTC (if asDateTime = \code{TRUE}), \cr
\tab character \tab or raw character string (if asDateTime = FALSE) \cr
tz_cd \tab character \tab The time zone code for datetime \cr
code \tab character \tab Any codes that qualify the corresponding value\cr
value \tab numeric \tab The numeric value for the parameter \cr
tz_cd_reported \tab The originally reported time zone \cr
}
Note that code and value are repeated for the parameters requested. The names are of the form
XD_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).
If a date/time (dt) column contained incomplete date and times, a new column of dates was inserted. This could happen
when older data was reported as dates, and newer data was reported as a date/time.

There are also several useful attributes attached to the data frame:
\tabular{lll}{
Name \tab Type \tab Description \cr
url \tab character \tab The url used to generate the data \cr
queryTime \tab POSIXct \tab The time the data was returned \cr
comment \tab character \tab Header comments from the RDB file \cr
}
Laura A DeCicco's avatar
Laura A DeCicco committed
}
\description{
Laura A DeCicco's avatar
Laura A DeCicco committed
This function accepts a url parameter that already contains the desired
Laura A DeCicco's avatar
Laura A DeCicco committed
NWIS site, parameter code, statistic, startdate and enddate. It is not
recommended to use the RDB format for importing multi-site data.
Laura A DeCicco's avatar
Laura A DeCicco committed
}
\examples{
siteNumber <- "02177000"
Laura A DeCicco's avatar
Laura A DeCicco committed
startDate <- "2012-09-01"
endDate <- "2012-10-01"
obs_url <- constructNWISURL(siteNumber,property,
data <- importRDB1(obs_url)

Laura A DeCicco's avatar
Laura A DeCicco committed
urlMultiPcodes <- constructNWISURL("04085427",c("00060","00010"),
         startDate,endDate,"dv",statCd=c("00003","00001"),"tsv")
Laura A DeCicco's avatar
Laura A DeCicco committed
multiData <- importRDB1(urlMultiPcodes)
unitDataURL <- constructNWISURL(siteNumber,property,
         "2013-11-03","2013-11-03","uv",format="tsv") #includes timezone switch
Laura A DeCicco's avatar
Laura A DeCicco committed
unitData <- importRDB1(unitDataURL, asDateTime=TRUE)
qwURL <- constructNWISURL(c('04024430','04024000'),
          c('34247','30234','32104','34220'),
         "2010-11-03","","qw",format="rdb")
qwData <- importRDB1(qwURL, qw=TRUE, tz="America/Chicago")
start <- "2014-11-09"
end <- "2014-11-28"
Laura A DeCicco's avatar
Laura A DeCicco committed
urlIce <- constructNWISURL(iceSite,"00060",start, end,"uv",format="tsv")
ice <- importRDB1(urlIce, asDateTime=TRUE)
iceNoConvert <- importRDB1(urlIce, convertType=FALSE)
}
Laura A DeCicco's avatar
Laura A DeCicco committed
filePath <- system.file("extdata", package="dataRetrieval")
fileName <- "RDB1Example.txt"
fullPath <- file.path(filePath, fileName)
importUserRDB <- importRDB1(fullPath)