Commit a25c2975 authored by Laura A DeCicco's avatar Laura A DeCicco
Browse files

Merge pull request #174 from ldecicco-USGS/master

Back to a connection.
parents afd06880 262ed249
......@@ -222,7 +222,7 @@ constructNWISURL <- function(siteNumber,parameterCd="00060",startDate="",endDate
#' retrieval for the earliest possible record.
#' @param endDate character ending date for data retrieval in the form YYYY-MM-DD. Default is "" which indicates
#' retrieval for the latest possible record.
#' @param zip logical to request data via downloading zip file. Default set to TRUE.
#' @param zip logical to request data via downloading zip file. Default set to FALSE.
#' @keywords data import WQP web service
#' @return url string
#' @export
......@@ -234,7 +234,7 @@ constructNWISURL <- function(siteNumber,parameterCd="00060",startDate="",endDate
#' url_wqp <- constructWQPURL(paste("USGS",siteNumber,sep="-"),
#' c('01075','00029','00453'),
#' startDate,endDate)
constructWQPURL <- function(siteNumber,parameterCd,startDate,endDate,zip=TRUE){
constructWQPURL <- function(siteNumber,parameterCd,startDate,endDate,zip=FALSE){
multipleSites <- length(siteNumber) > 1
multiplePcodes <- length(parameterCd)>1
......
......@@ -5,7 +5,7 @@
#' Imports data from the Water Quality Portal based on a specified url.
#'
#' @param obs_url character URL to Water Quality Portal#' @keywords data import USGS web service
#' @param zip logical to request data via downloading zip file. Default set to TRUE.
#' @param zip logical to request data via downloading zip file. Default set to FALSE.
#' @param 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",
......@@ -44,7 +44,7 @@
#' STORETex <- constructWQPURL('WIDNR_WQX-10032762','Specific conductance', '', '')
#' STORETdata <- importWQP(STORETex)
#' }
importWQP <- function(obs_url, zip=TRUE, tz=""){
importWQP <- function(obs_url, zip=FALSE, tz=""){
if(tz != ""){
tz <- match.arg(tz, c("America/New_York","America/Chicago",
......@@ -57,8 +57,9 @@ importWQP <- function(obs_url, zip=TRUE, tz=""){
if(!file.exists(obs_url)){
if(zip){
message("zip encoding access still in development")
temp <- tempfile()
# options(timeout = 120)
options(timeout = 120)
h <- basicHeaderGatherer()
myOpts = curlOptions(verbose = FALSE,
header = FALSE,
......@@ -88,7 +89,10 @@ importWQP <- function(obs_url, zip=TRUE, tz=""){
if(zip){
temp <- paste0(temp,".zip")
writeBin(doc, temp)
f <- file(temp, "wb")
writeBin(doc, con = f)
close(f)
doc <- unzip(temp)
}
......
......@@ -4,7 +4,7 @@
#' because it allows for other agencies rather than the USGS.
#'
#' @param \dots see \url{www.waterqualitydata.us/webservices_documentation.jsp} for a complete list of options
#' @param zip logical to request data via downloading zip file. Default set to TRUE.
#' @param zip logical to request data via downloading zip file. Default set to FALSE.
#' @keywords data import WQP web service
#' @return A data frame with at least the following columns:
#' \tabular{lll}{
......@@ -97,7 +97,7 @@
#'
#'
#' }
readWQPdata <- function(..., zip=TRUE){
readWQPdata <- function(..., zip=FALSE){
matchReturn <- list(...)
......
......@@ -4,7 +4,7 @@
#' Arguments to the function should be based on \url{www.waterqualitydata.us/webservices_documentation.jsp}
#'
#' @param \dots see \url{www.waterqualitydata.us/webservices_documentation.jsp} for a complete list of options
#' @param zip logical to request data via downloading zip file. Default set to TRUE.
#' @param zip logical to request data via downloading zip file. Default set to FALSE.
#' @keywords data import WQP web service
#' @return A data frame with at least the following columns:
#' \tabular{lll}{
......@@ -58,7 +58,7 @@
#' sites <- whatWQPsites(countycode="US:55:025",siteType=type)
#' lakeSites <- whatWQPsites(siteType = "Lake, Reservoir, Impoundment", statecode = "US:55")
#' }
whatWQPsites <- function(...,zip=TRUE){
whatWQPsites <- function(...,zip=FALSE){
matchReturn <- list(...)
......
......@@ -4,7 +4,7 @@
\alias{constructWQPURL}
\title{Construct WQP url for data retrieval}
\usage{
constructWQPURL(siteNumber, parameterCd, startDate, endDate, zip = TRUE)
constructWQPURL(siteNumber, parameterCd, startDate, endDate, zip = FALSE)
}
\arguments{
\item{siteNumber}{string or vector of strings USGS site number. This is usually an 8 digit number}
......@@ -17,7 +17,7 @@ retrieval for the earliest possible record.}
\item{endDate}{character ending date for data retrieval in the form YYYY-MM-DD. Default is "" which indicates
retrieval for the latest possible record.}
\item{zip}{logical to request data via downloading zip file. Default set to TRUE.}
\item{zip}{logical to request data via downloading zip file. Default set to FALSE.}
}
\value{
url string
......
......@@ -4,12 +4,12 @@
\alias{importWQP}
\title{Basic Water Quality Portal Data parser}
\usage{
importWQP(obs_url, zip = TRUE, tz = "")
importWQP(obs_url, zip = FALSE, tz = "")
}
\arguments{
\item{obs_url}{character URL to Water Quality Portal#' @keywords data import USGS web service}
\item{zip}{logical to request data via downloading zip file. Default set to TRUE.}
\item{zip}{logical to request data via downloading zip file. Default set to FALSE.}
\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).
......
......@@ -4,10 +4,10 @@
\alias{readWQPdata}
\title{General Data Import from Water Quality Portal}
\usage{
readWQPdata(..., zip = TRUE)
readWQPdata(..., zip = FALSE)
}
\arguments{
\item{zip}{logical to request data via downloading zip file. Default set to TRUE.}
\item{zip}{logical to request data via downloading zip file. Default set to FALSE.}
\item{\dots}{see \url{www.waterqualitydata.us/webservices_documentation.jsp} for a complete list of options}
}
......
......@@ -4,10 +4,10 @@
\alias{whatWQPsites}
\title{Site Data Import from Water Quality Portal}
\usage{
whatWQPsites(..., zip = TRUE)
whatWQPsites(..., zip = FALSE)
}
\arguments{
\item{zip}{logical to request data via downloading zip file. Default set to TRUE.}
\item{zip}{logical to request data via downloading zip file. Default set to FALSE.}
\item{\dots}{see \url{www.waterqualitydata.us/webservices_documentation.jsp} for a complete list of options}
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment