Skip to content
Snippets Groups Projects
importWaterML1.Rd 4.23 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/importWaterML1.r
Laura A DeCicco's avatar
Laura A DeCicco committed
\name{importWaterML1}
\alias{importWaterML1}
\title{Function to return data from the NWISWeb WaterML1.1 service}
Laura A DeCicco's avatar
Laura A DeCicco committed
\usage{
importWaterML1(obs_url, asDateTime = FALSE, 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}
\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{
Laura A DeCicco's avatar
Laura A DeCicco committed
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 = 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
}
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:
\tabular{lll}{
Laura A DeCicco's avatar
Laura A DeCicco committed
Name \tab Type \tab Description \cr
url \tab character \tab The url used to generate the data \cr
siteInfo \tab data.frame \tab A data frame containing information on the requested sites \cr
variableInfo \tab data.frame \tab A data frame containing information on the requested parameters \cr
statisticInfo \tab data.frame \tab A data frame containing information on the requested statistics on the data \cr
queryTime \tab POSIXct \tab The time the data was returned \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
NWIS site, parameter code, statistic, startdate and enddate.
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"
offering <- '00003'
property <- '00060'
obs_url <- constructNWISURL(siteNumber,property,startDate,endDate,'dv')
Laura A DeCicco's avatar
Laura A DeCicco committed
\dontrun{
data <- importWaterML1(obs_url)
groundWaterSite <- "431049071324301"
startGW <- "2013-10-01"
endGW <- "2014-06-30"
groundwaterExampleURL <- constructNWISURL(groundWaterSite, NA,
Laura A DeCicco's avatar
Laura A DeCicco committed
          startGW,endGW, service="gwlevels")
Laura A DeCicco's avatar
Laura A DeCicco committed
groundWater <- importWaterML1(groundwaterExampleURL)
groundWater2 <- importWaterML1(groundwaterExampleURL, asDateTime=TRUE)
unitDataURL <- constructNWISURL(siteNumber,property,
Laura A DeCicco's avatar
Laura A DeCicco committed
         "2013-11-03","2013-11-03",'uv')
unitData <- importWaterML1(unitDataURL,TRUE)
Laura A DeCicco's avatar
Laura A DeCicco committed

# Two sites, two pcodes, one site has two data descriptors:
siteNumber <- c('01480015',"04085427")
obs_url <- constructNWISURL(siteNumber,c("00060","00010"),startDate,endDate,'dv')
data <- importWaterML1(obs_url)
data$dateTime <- as.Date(data$dateTime)
data <- renameNWISColumns(data)
names(attributes(data))
attr(data, "url")
attr(data, "disclaimer")
Laura A DeCicco's avatar
Laura A DeCicco committed

inactiveSite <- "05212700"
inactiveSite <- constructNWISURL(inactiveSite, "00060", "2014-01-01", "2014-01-10",'dv')
inactiveSite <- importWaterML1(inactiveSite)

inactiveAndAcitive <- c("07334200","05212700")
inactiveAndAcitive <- constructNWISURL(inactiveAndAcitive, "00060", "2014-01-01", "2014-01-10",'dv')
inactiveAndAcitive <- importWaterML1(inactiveAndAcitive)
Timezone change with specified local timezone:
tzURL <- constructNWISURL("04027000", c("00300","63680"), "2011-11-05", "2011-11-07","uv")
tzIssue <- importWaterML1(tzURL, TRUE, "America/Chicago")


Laura A DeCicco's avatar
Laura A DeCicco committed
}
filePath <- system.file("extdata", package="dataRetrieval")
fileName <- "WaterML1Example.xml"
fullPath <- file.path(filePath, fileName)
imporFile <- importWaterML1(fullPath,TRUE)
Laura A DeCicco's avatar
Laura A DeCicco committed
}
Laura A DeCicco's avatar
Laura A DeCicco committed
\seealso{
\code{\link{renameNWISColumns}}
Laura A DeCicco's avatar
Laura A DeCicco committed
}
Laura A DeCicco's avatar
Laura A DeCicco committed