Commit 2a2f5628 authored by Laura A DeCicco's avatar Laura A DeCicco
Browse files

Fixes #317

parent 74e185f7
......@@ -5,9 +5,8 @@
#'
#' @param input character or raw, containing the url for the retrieval or a path to the data file, or raw XML.
#' @param asDateTime logical, if \code{TRUE} returns date and time as POSIXct, if \code{FALSE}, character
#' @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 time zone offset).
#' Possible values are "America/New_York","America/Chicago", "America/Denver","America/Los_Angeles",
#' @param tz character to set timezone attribute of datetime. Default is UTC (properly accounting for daylight savings times based on the data's provided time zone offset).
#' Possible values include "America/New_York","America/Chicago", "America/Denver","America/Los_Angeles",
#' "America/Anchorage","America/Honolulu","America/Jamaica","America/Managua","America/Phoenix", and "America/Metlakatla"
#' @return mergedDF a data frame source, time, value, uom, uomTitle, comment, gmlID
#' @export
......
......@@ -6,9 +6,8 @@
#'
#' @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 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",
#' @param tz character to set timezone attribute of datetime. Default is UTC (properly accounting for daylight savings times based on the data's provided tz_cd column).
#' Possible values include "America/New_York","America/Chicago", "America/Denver","America/Los_Angeles",
#' "America/Anchorage","America/Honolulu","America/Jamaica","America/Managua","America/Phoenix", and "America/Metlakatla"
#' @return retval dataframe raw data returned from the Water Quality Portal. Additionally, a POSIXct dateTime column is supplied for
#' start and end times, and converted to UTC. See \url{https://www.waterqualitydata.us/portal_userguide/} for more information.
......@@ -44,7 +43,7 @@
#' STORETex <- constructWQPURL('WIDNR_WQX-10032762','Specific conductance', '', '')
#' STORETdata <- importWQP(STORETex)
#' }
importWQP <- function(obs_url, zip=FALSE, tz=""){
importWQP <- function(obs_url, zip=FALSE, tz="UTC"){
if(tz != ""){
tz <- match.arg(tz, OlsonNames())
......
......@@ -129,6 +129,12 @@
#' dailyLexingtonVA <- readWQPdata(statecode = "Virginia",
#' countycode="Lexington",
#' parameterCd = "00010")
#'
#' # Biological data:
#' bioData <- readWQPdata(statecode = "WI",
#' countycode = "Dane",
#' providers = "BIODATA")
#'
#' }
readWQPdata <- function(..., querySummary=FALSE, tz="UTC"){
......
......@@ -11,9 +11,8 @@ importNGWMN(input, asDateTime = FALSE, tz = "UTC")
\item{asDateTime}{logical, if \code{TRUE} returns date and time as POSIXct, if \code{FALSE}, 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 time zone offset).
Possible values are "America/New_York","America/Chicago", "America/Denver","America/Los_Angeles",
\item{tz}{character to set timezone attribute of datetime. Default is UTC (properly accounting for daylight savings times based on the data's provided time zone offset).
Possible values include "America/New_York","America/Chicago", "America/Denver","America/Los_Angeles",
"America/Anchorage","America/Honolulu","America/Jamaica","America/Managua","America/Phoenix", and "America/Metlakatla"}
}
\value{
......
......@@ -4,16 +4,15 @@
\alias{importWQP}
\title{Basic Water Quality Portal Data parser}
\usage{
importWQP(obs_url, zip = FALSE, tz = "")
importWQP(obs_url, zip = FALSE, tz = "UTC")
}
\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 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).
Possible values to provide are "America/New_York","America/Chicago", "America/Denver","America/Los_Angeles",
\item{tz}{character to set timezone attribute of datetime. Default is UTC (properly accounting for daylight savings times based on the data's provided tz_cd column).
Possible values include "America/New_York","America/Chicago", "America/Denver","America/Los_Angeles",
"America/Anchorage","America/Honolulu","America/Jamaica","America/Managua","America/Phoenix", and "America/Metlakatla"}
}
\value{
......
......@@ -140,6 +140,12 @@ wqp.summary_WI <- readWQPdata(arg_3, statecode="WI",
dailyLexingtonVA <- readWQPdata(statecode = "Virginia",
countycode="Lexington",
parameterCd = "00010")
# Biological data:
bioData <- readWQPdata(statecode = "WI",
countycode = "Dane",
providers = "BIODATA")
}
}
\keyword{WQP}
......
......@@ -131,6 +131,13 @@ test_that("General WQP retrievals working", {
expect_equal(ncol(dailyLexingtonVA),65)
bioData <- readWQPdata(statecode = "WI",
countycode = "Dane",
providers = "BIODATA")
expect_equal(attr(bioData, "url"), "https://www.waterqualitydata.us/Result/search?statecode=US%3A55&countycode=US%3A55%3A025&providers=BIODATA&zip=no&sorted=no&mimeType=tsv")
expect_gt(nrow(bioData), 1)
# Known slow query for WQP:
# pHDataExpanded2 <- readWQPdata(bBox=c(-90.1,42.9,-89.9,43.1),
# characteristicName=nameToUse, querySummary = TRUE)
......
......@@ -359,5 +359,36 @@ test_that("Construct NWIS urls", {
urlQW <- constructNWISURL("450456092225801","70300",startDate="",endDate="","qw",expanded=TRUE)
expect_equal(urlQW, "https://nwis.waterdata.usgs.gov/nwis/qwdata?search_site_no=450456092225801&search_site_no_match_type=exact&multiple_parameter_cds=70300&param_cd_operator=AND&list_of_search_criteria=search_site_no,multiple_parameter_cds&group_key=NONE&sitefile_output_format=html_table&column_name=agency_cd&column_name=site_no&column_name=station_nm&inventory_output=0&rdb_inventory_output=file&TZoutput=0&pm_cd_compare=Greater%20than&radio_parm_cds=previous_parm_cds&qw_attributes=0&format=rdb&rdb_qw_attributes=expanded&date_format=YYYY-MM-DD&rdb_compression=value&qw_sample_wide=0")
url_use <- constructUseURL(years=c(1990,1995),stateCd="Ohio",countyCd = c(1,3), categories = "ALL")
expect_equal(url_use, "https://waterdata.usgs.gov/OH/nwis/water_use?format=rdb&rdb_compression=value&wu_area=county&wu_county=1%2C3&wu_year=1990%2C1995&wu_category=ALL")
})
context("Construct WQP urls")
test_that("Construct WQP urls", {
})
context("checkWQPdates")
test_that("checkWQPdates", {
values <- list(startDateLo="01-01-2002", characteristicName="Phosphorous",
endDate=as.Date("2014-01-01"))
values1 <- checkWQPdates(values)
expect_equal(values1$startDateHi, "01-01-2014")
expect_equal(values1$startDateLo, "01-01-2002")
})
context("Construct NWIS urls")
test_that("Construct NWIS urls", {
siteNumber <- '01594440'
startDate <- '1985-01-01'
endDate <- ''
pCode <- c("00060","00010")
url_wqp <- constructWQPURL(paste("USGS",siteNumber,sep="-"),
c('01075','00029','00453'),
startDate,endDate)
expect_equal(url_wqp, "https://www.waterqualitydata.us/Result/search?siteid=USGS-01594440&pCode=01075;00029;00453&startDateLo=01-01-1985&sorted=no&mimeType=tsv")
rawSampleURL_Zip <- constructWQPURL('USGS-01594440','01075', '', '', TRUE)
expect_equal(rawSampleURL_Zip, "https://www.waterqualitydata.us/Result/search?siteid=USGS-01594440&pCode=01075&sorted=no&mimeType=tsv&zip=yes")
})
\ No newline at end of file
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