Skip to content

Commit

Permalink
Merge pull request #174 from ldecicco-USGS/master
Browse files Browse the repository at this point in the history
Back to a connection.
  • Loading branch information
ldecicco-USGS committed Feb 3, 2016
2 parents afd0688 + 262ed24 commit a25c297
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 18 deletions.
4 changes: 2 additions & 2 deletions R/constructNWISURL.r
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
12 changes: 8 additions & 4 deletions R/importWQP.R
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand All @@ -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,
Expand Down Expand Up @@ -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)
}

Expand Down
4 changes: 2 additions & 2 deletions R/readWQPdata.R
Original file line number Diff line number Diff line change
Expand Up @@ -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}{
Expand Down Expand Up @@ -97,7 +97,7 @@
#'
#'
#' }
readWQPdata <- function(..., zip=TRUE){
readWQPdata <- function(..., zip=FALSE){

matchReturn <- list(...)

Expand Down
4 changes: 2 additions & 2 deletions R/whatWQPsites.R
Original file line number Diff line number Diff line change
Expand Up @@ -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}{
Expand Down Expand Up @@ -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(...)

Expand Down
4 changes: 2 additions & 2 deletions man/constructWQPURL.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions man/importWQP.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions man/readWQPdata.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions man/whatWQPsites.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit a25c297

Please sign in to comment.