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

https links

parent 05cb7add
#' Construct NWIS url for data retrieval
#'
#' Imports data from NWIS web service. This function gets the data from here: \url{http://nwis.waterdata.usgs.gov/nwis/qwdata}
#' A list of parameter codes can be found here: \url{http://nwis.waterdata.usgs.gov/nwis/pmcodes/}
#' A list of statistic codes can be found here: \url{http://nwis.waterdata.usgs.gov/nwis/help/?read_file=stat&format=table}
#' Imports data from NWIS web service. This function gets the data from here: \url{https://nwis.waterdata.usgs.gov/nwis/qwdata}
#' A list of parameter codes can be found here: \url{https://nwis.waterdata.usgs.gov/nwis/pmcodes/}
#' A list of statistic codes can be found here: \url{https://nwis.waterdata.usgs.gov/nwis/help/?read_file=stat&format=table}
#'
#' @param siteNumber string or vector of strings USGS site number. This is usually an 8 digit number
#' @param parameterCd string or vector of USGS parameter code. This is usually an 5 digit number.
......@@ -26,7 +26,7 @@
#' provide statistics for each month and year within the range individually.
#' @param statType character Only used for statistics service requests. Type(s) of statistics to output for daily values. Default is mean, which is the only
#' option for monthly and yearly report types. See the statistics service documentation
#' at \url{http://waterservices.usgs.gov/rest/Statistics-Service.html#statType} for a full list of codes.
#' at \url{https://waterservices.usgs.gov/rest/Statistics-Service.html#statType} for a full list of codes.
#' @keywords data import USGS web service
#' @return url string
#' @export
......@@ -321,7 +321,7 @@ constructWQPURL <- function(siteNumber,parameterCd,startDate,endDate,zip=FALSE){
#' Construct URL for NWIS water use data service
#'
#' Reconstructs URLs to retrieve data from here: \url{http://waterdata.usgs.gov/nwis/wu}
#' Reconstructs URLs to retrieve data from here: \url{https://waterdata.usgs.gov/nwis/wu}
#'
#' @param years integer Years for data retrieval. Must be years ending in 0 or 5, or "ALL", which retrieves all available years.
#' @param stateCd could be character (full name, abbreviation, id), or numeric (id)
......
......@@ -11,7 +11,7 @@
#' 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"
#' @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{http://www.waterqualitydata.us/portal_userguide/} for more information.
#' start and end times, and converted to UTC. See \url{https://www.waterqualitydata.us/portal_userguide/} for more information.
#' @export
#' @seealso \code{\link{readWQPdata}}, \code{\link{readWQPqw}}, \code{\link{whatWQPsites}}
#' @import utils
......
......@@ -154,9 +154,9 @@ importWaterML1 <- function(obs_url,asDateTime=FALSE, tz=""){
#descriptor will be appended to col name if so
valParents <- xml_find_all(t,".//ns1:values")
obsDF <- NULL
useMethodDesc <- FALSE
if(length(valParents) > 1){ useMethodDesc <- TRUE} #append the method description to colnames later
useMethodDesc <- length(valParents) > 1 #append the method description to colnames later
sourceInfo <- xml_children(xml_find_all(t, ".//ns1:sourceInfo"))
variable <- xml_children(xml_find_all(t, ".//ns1:variable"))
agency_cd <- xml_attr(sourceInfo[xml_name(sourceInfo)=="siteCode"],"agencyCode")
......@@ -185,72 +185,76 @@ importWaterML1 <- function(obs_url,asDateTime=FALSE, tz=""){
for(v in valParents){
obsColName <- paste(pCode,statCode,sep = "_")
obs <- xml_find_all(v, ".//ns1:value")
values <- as.numeric(xml_text(obs)) #actual observations
nObs <- length(values)
qual <- xml_attr(obs,"qualifiers")
if(all(is.na(qual))){
noQual <- TRUE
}else{noQual <- FALSE}
dateTime <- xml_attr(obs,"dateTime")
if(asDateTime){
numChar <- nchar(dateTime)
dateTime <- parse_date_time(dateTime, c("%Y","%Y-%m-%d","%Y-%m-%dT%H:%M",
"%Y-%m-%dT%H:%M:%S","%Y-%m-%dT%H:%M:%OS",
"%Y-%m-%dT%H:%M:%OS%z"), exact = TRUE)
if(any(numChar < 20) & any(numChar > 16)){
offsetLibrary <- data.frame(offset=c(5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10, 10, 0),
code=c("EST","EDT","CST","CDT","MST","MDT","PST","PDT","AKST","AKDT","HAST","HST",""),
stringsAsFactors = FALSE)
#not sure there is still a case for this (no offset on times)?
dateTime[numChar < 20 & numChar > 16] <- dateTime[numChar < 20 & numChar > 16] + offsetLibrary[offsetLibrary$code == defaultTZ,"offset"]*60*60
warning(paste("site",site_no[1], "had data without time zone offsets, so DST could not be accounted for"))
}
if(length(obs) > 0){
values <- as.numeric(xml_text(obs)) #actual observations
nObs <- length(values)
qual <- xml_attr(obs,"qualifiers")
#^^setting tz in as.POSIXct just sets the attribute, does not convert the time!
attr(dateTime, 'tzone') <- tz
tzCol <- rep(tz,nObs)
}else{
tzCol <- rep(defaultTZ, nObs)
}
#create column names, addressing if methodDesc is needed
if(useMethodDesc){
methodDesc <- xml_text(xml_find_all(v, ".//ns1:methodDescription"))
#this keeps column names consistent with old version
methodDesc <- gsub("\\[|\\]| |\\(|\\)",".",methodDesc)
noQual <- all(is.na(qual))
dateTime <- xml_attr(obs,"dateTime")
#sometimes methodDesc is empty
if(nchar(methodDesc) > 0){
obsColName <- paste("X",methodDesc,obsColName, sep = "_")
if(asDateTime){
numChar <- nchar(dateTime)
dateTime <- parse_date_time(dateTime, c("%Y","%Y-%m-%d","%Y-%m-%dT%H:%M",
"%Y-%m-%dT%H:%M:%S","%Y-%m-%dT%H:%M:%OS",
"%Y-%m-%dT%H:%M:%OS%z"), exact = TRUE)
if(any(numChar < 20) & any(numChar > 16)){
offsetLibrary <- data.frame(offset=c(5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10, 10, 0),
code=c("EST","EDT","CST","CDT","MST","MDT","PST","PDT","AKST","AKDT","HAST","HST",""),
stringsAsFactors = FALSE)
#not sure there is still a case for this (no offset on times)?
dateTime[numChar < 20 & numChar > 16] <- dateTime[numChar < 20 & numChar > 16] + offsetLibrary[offsetLibrary$code == defaultTZ,"offset"]*60*60
warning(paste("site",site_no[1], "had data without time zone offsets, so DST could not be accounted for"))
}
#^^setting tz in as.POSIXct just sets the attribute, does not convert the time!
attr(dateTime, 'tzone') <- tz
tzCol <- rep(tz,nObs)
}else{
tzCol <- rep(defaultTZ, nObs)
}
#create column names, addressing if methodDesc is needed
if(useMethodDesc){
methodDesc <- xml_text(xml_find_all(v, ".//ns1:methodDescription"))
#this keeps column names consistent with old version
methodDesc <- gsub("\\[|\\]| |\\(|\\)",".",methodDesc)
#sometimes methodDesc is empty
if(nchar(methodDesc) > 0){
obsColName <- paste("X",methodDesc,obsColName, sep = "_")
}else{
obsColName <- paste("X",obsColName, sep = "_")
}
} else{
obsColName <- paste("X",obsColName, sep = "_")
}
} else{
obsColName <- paste("X",obsColName, sep = "_")
}
qualColName <- paste(obsColName,"cd",sep = "_")
valParentDF <- cbind.data.frame(dateTime, values, qual, tzCol, stringsAsFactors = FALSE)
names(valParentDF) <- c("dateTime",obsColName, qualColName, "tz_cd")
#delete qual column if all NA
if(all(is.na(valParentDF[,eval(qualColName)]))){
valParentDF <- subset(valParentDF, select = c("dateTime", eval(obsColName), "tz_cd"))
}
if(nrow(valParentDF) > 0){
if(is.null(obsDF)){
obsDF <- valParentDF
}else{
obsDF <- full_join(obsDF, valParentDF, by = c("dateTime","tz_cd"))
qualColName <- paste(obsColName,"cd",sep = "_")
valParentDF <- cbind.data.frame(dateTime, values, qual, tzCol, stringsAsFactors = FALSE)
names(valParentDF) <- c("dateTime",obsColName, qualColName, "tz_cd")
#delete qual column if all NA
if(all(is.na(valParentDF[,eval(qualColName)]))){
valParentDF <- subset(valParentDF, select = c("dateTime", eval(obsColName), "tz_cd"))
}
}else{
#need column names for joining later
obsDF <- data.frame(dateTime=character(0), tz_cd=character(0), stringsAsFactors = FALSE)
if(asDateTime){
obsDF$dateTime <- as.POSIXct(obsDF$dateTime)
attr(obsDF$dateTime, "tzone") <- tz
if(nrow(valParentDF) > 0){
if(is.null(obsDF)){
obsDF <- valParentDF
} else {
obsDF <- full_join(obsDF, valParentDF, by = c("dateTime","tz_cd"))
}
} else {
#need column names for joining later
obsDF <- data.frame(dateTime=character(0), tz_cd=character(0), stringsAsFactors = FALSE)
if(asDateTime){
obsDF$dateTime <- as.POSIXct(obsDF$dateTime)
attr(obsDF$dateTime, "tzone") <- tz
}
}
}
}
......
......@@ -18,19 +18,14 @@
#' @importFrom dplyr rbind_all
#' @importFrom lubridate parse_date_time
#' @examples
#' baseURL <- "http://waterservices.usgs.gov/nwis/dv/?format=waterml,2.0"
#' baseURL <- "https://waterservices.usgs.gov/nwis/dv/?format=waterml,2.0"
#' URL <- paste(baseURL, "sites=01646500",
#' "startDT=2014-09-01",
#' "endDT=2014-09-08",
#' "statCd=00003",
#' "parameterCd=00060",sep="&")
#' URL2 <- paste("http://cida.usgs.gov/noreast-sos/simple?request=GetObservation",
#' "featureID=MD-BC-BC-05",
#' "offering=RAW",
#' "observedProperty=WATER",sep="&")
#' \dontrun{
#' dataReturned1 <- importWaterML2(URL)
#' dataReturn2 <- importWaterML2(URL2, TRUE)
#' URLmulti <- paste(baseURL,
#' "sites=04024430,04024000",
#' "startDT=2014-09-01",
......
#' General Data Import from NWIS
#'
#' Returns data from the NWIS web service.
#' Arguments to the function should be based on \url{http://waterservices.usgs.gov} service calls.
#' Arguments to the function should be based on \url{https://waterservices.usgs.gov} service calls.
#' See examples below for ideas of constructing queries.
#'
#' @param service character. Possible values are "iv" (for instantaneous), "dv" (for daily values), "gwlevels"
#' (for groundwater levels), "site" (for site service), "qw" (water-quality),"measurement", and "stat" (for
#' statistics service). Note: "qw" and "measurement" calls go to:
#' \url{http://nwis.waterdata.usgs.gov/usa/nwis} for data requests, and use different call requests schemes.
#' The statistics service has a limited selection of arguments (see \url{http://waterservices.usgs.gov/rest/Statistics-Service-Test-Tool.html}).
#' \url{https://nwis.waterdata.usgs.gov/usa/nwis} for data requests, and use different call requests schemes.
#' The statistics service has a limited selection of arguments (see \url{https://waterservices.usgs.gov/rest/Statistics-Service-Test-Tool.html}).
#' @param asDateTime logical, if \code{TRUE} returns date and time as POSIXct, if \code{FALSE}, Date
#' @param 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
#' @param \dots see \url{http://waterservices.usgs.gov/rest/Site-Service.html#Service} for a complete list of options
#' @param \dots see \url{https://waterservices.usgs.gov/rest/Site-Service.html#Service} for a complete list of options
#' @import utils
#' @import stats
#' @return A data frame with the following columns:
......@@ -126,7 +126,6 @@ readNWISdata <- function(service="dv", ..., asDateTime=TRUE,convertType=TRUE){
names(values)[names(values) == "siteNumbers"] <- "sites"
format.default <- "waterml,1.1"
baseURL <- "http://waterservices.usgs.gov/nwis/"
if("stateCd" %in% names(values)){
values["stateCd"] <- stateCdLookup(values["stateCd"], "postal")
......@@ -137,7 +136,6 @@ readNWISdata <- function(service="dv", ..., asDateTime=TRUE,convertType=TRUE){
names(values)[names(values) == "statecode"] <- "stateCd"
}
if (service %in% c("qwdata","measurements")){
format.default <- "rdb"
......
#' Daily Value USGS NWIS Data Retrieval
#'
#' Imports data from NWIS web service. This function gets the data from here: \url{http://waterservices.usgs.gov/}
#' Imports data from NWIS web service. This function gets the data from here: \url{https://waterservices.usgs.gov/}
#'
#' @param siteNumber character USGS site number. This is usually an 8 digit number. Multiple sites can be requested with a character vector.
#' @param parameterCd character of USGS parameter code(s). This is usually an 5 digit number.
......
#' USGS Parameter Data Retrieval
#'
#' Imports data from NWIS about meaured parameter based on user-supplied parameter code or codes.
#' This function gets the data from here: \url{http://nwis.waterdata.usgs.gov/nwis/pmcodes}
#' This function gets the data from here: \url{https://nwis.waterdata.usgs.gov/nwis/pmcodes}
#'
#' @param parameterCd character of USGS parameter codes (or multiple parameter codes). These are 5 digit number codes,
#' more information can be found here: \url{http://help.waterdata.usgs.gov/}. To get a
#' more information can be found here: \url{https://help.waterdata.usgs.gov/}. To get a
#' complete list of all current parameter codes in the USGS, use "all" as the input.
#' @keywords data import USGS web service
#' @return parameterData data frame with the following information:
......@@ -29,7 +29,7 @@ readNWISpCode <- function(parameterCd){
parameterCd <- parameterCd[!is.na(parameterCd)]
if(any(parameterCd == "all")){
fullURL <- "http://nwis.waterdata.usgs.gov/nwis/pmcodes/pmcodes?radio_pm_search=param_group&pm_group=All+--+include+all+parameter+groups&format=rdb&show=parameter_group_nm&show=parameter_nm&show=casrn&show=srsname&show=parameter_units"
fullURL <- "https://nwis.waterdata.usgs.gov/nwis/pmcodes/pmcodes?radio_pm_search=param_group&pm_group=All+--+include+all+parameter+groups&format=rdb&show=parameter_group_nm&show=parameter_nm&show=casrn&show=srsname&show=parameter_units"
parameterData <- importRDB1(fullURL, asDateTime = FALSE)
} else {
pcodeCheck <- all(nchar(parameterCd) == 5) & all(!is.na(suppressWarnings(as.numeric(parameterCd))))
......@@ -37,14 +37,14 @@ readNWISpCode <- function(parameterCd){
if(nrow(parameterData) != length(parameterCd)){
if(length(parameterCd) == 1){
url <- paste0("http://nwis.waterdata.usgs.gov/nwis/pmcodes/pmcodes?radio_pm_search=pm_search",
suburl <- paste0("https://nwis.waterdata.usgs.gov/nwis/pmcodes/pmcodes?radio_pm_search=pm_search",
"&pm_search=", parameterCd,
"&format=rdb", "&show=parameter_group_nm",
"&show=parameter_nm", "&show=casrn",
"&show=srsname", "&show=parameter_units")
parameterData <- importRDB1(url,asDateTime = FALSE)
parameterData <- importRDB1(suburl,asDateTime = FALSE)
} else {
fullURL <- "http://nwis.waterdata.usgs.gov/nwis/pmcodes/pmcodes?radio_pm_search=param_group&pm_group=All+--+include+all+parameter+groups&format=rdb&show=parameter_group_nm&show=parameter_nm&show=casrn&show=srsname&show=parameter_units"
fullURL <- "https://nwis.waterdata.usgs.gov/nwis/pmcodes/pmcodes?radio_pm_search=param_group&pm_group=All+--+include+all+parameter+groups&format=rdb&show=parameter_group_nm&show=parameter_nm&show=casrn&show=srsname&show=parameter_units"
fullPcodeDownload <- importRDB1(fullURL)
parameterData <- fullPcodeDownload[fullPcodeDownload$parameter_cd %in% parameterCd,]
}
......
......@@ -42,15 +42,15 @@ provide statistics for each month and year within the range individually.}
\item{statType}{character Only used for statistics service requests. Type(s) of statistics to output for daily values. Default is mean, which is the only
option for monthly and yearly report types. See the statistics service documentation
at \url{http://waterservices.usgs.gov/rest/Statistics-Service.html#statType} for a full list of codes.}
at \url{https://waterservices.usgs.gov/rest/Statistics-Service.html#statType} for a full list of codes.}
}
\value{
url string
}
\description{
Imports data from NWIS web service. This function gets the data from here: \url{http://nwis.waterdata.usgs.gov/nwis/qwdata}
A list of parameter codes can be found here: \url{http://nwis.waterdata.usgs.gov/nwis/pmcodes/}
A list of statistic codes can be found here: \url{http://nwis.waterdata.usgs.gov/nwis/help/?read_file=stat&format=table}
Imports data from NWIS web service. This function gets the data from here: \url{https://nwis.waterdata.usgs.gov/nwis/qwdata}
A list of parameter codes can be found here: \url{https://nwis.waterdata.usgs.gov/nwis/pmcodes/}
A list of statistic codes can be found here: \url{https://nwis.waterdata.usgs.gov/nwis/help/?read_file=stat&format=table}
}
\examples{
siteNumber <- '01594440'
......
......@@ -19,7 +19,7 @@ constructUseURL(years, stateCd, countyCd, categories)
url string
}
\description{
Reconstructs URLs to retrieve data from here: \url{http://waterdata.usgs.gov/nwis/wu}
Reconstructs URLs to retrieve data from here: \url{https://waterdata.usgs.gov/nwis/wu}
}
\examples{
url <- constructUseURL(years=c(1990,1995),stateCd="Ohio",countyCd = c(1,3), categories = "ALL")
......
......@@ -24,19 +24,14 @@ This function accepts a url parameter for a WaterML2 getObservation. This functi
but the general functionality is correct.
}
\examples{
baseURL <- "http://waterservices.usgs.gov/nwis/dv/?format=waterml,2.0"
baseURL <- "https://waterservices.usgs.gov/nwis/dv/?format=waterml,2.0"
URL <- paste(baseURL, "sites=01646500",
"startDT=2014-09-01",
"endDT=2014-09-08",
"statCd=00003",
"parameterCd=00060",sep="&")
URL2 <- paste("http://cida.usgs.gov/noreast-sos/simple?request=GetObservation",
"featureID=MD-BC-BC-05",
"offering=RAW",
"observedProperty=WATER",sep="&")
\dontrun{
dataReturned1 <- importWaterML2(URL)
dataReturn2 <- importWaterML2(URL2, TRUE)
URLmulti <- paste(baseURL,
"sites=04024430,04024000",
"startDT=2014-09-01",
......
......@@ -10,15 +10,15 @@ readNWISdata(service = "dv", ..., asDateTime = TRUE, convertType = TRUE)
\item{service}{character. Possible values are "iv" (for instantaneous), "dv" (for daily values), "gwlevels"
(for groundwater levels), "site" (for site service), "qw" (water-quality),"measurement", and "stat" (for
statistics service). Note: "qw" and "measurement" calls go to:
\url{http://nwis.waterdata.usgs.gov/usa/nwis} for data requests, and use different call requests schemes.
The statistics service has a limited selection of arguments (see \url{http://waterservices.usgs.gov/rest/Statistics-Service-Test-Tool.html}).}
\url{https://nwis.waterdata.usgs.gov/usa/nwis} for data requests, and use different call requests schemes.
The statistics service has a limited selection of arguments (see \url{https://waterservices.usgs.gov/rest/Statistics-Service-Test-Tool.html}).}
\item{asDateTime}{logical, if \code{TRUE} returns date and time as POSIXct, if \code{FALSE}, Date}
\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{\dots}{see \url{http://waterservices.usgs.gov/rest/Site-Service.html#Service} for a complete list of options}
\item{\dots}{see \url{https://waterservices.usgs.gov/rest/Site-Service.html#Service} for a complete list of options}
}
\value{
A data frame with the following columns:
......@@ -53,7 +53,7 @@ queryTime \tab POSIXct \tab The time the data was returned \cr
}
\description{
Returns data from the NWIS web service.
Arguments to the function should be based on \url{http://waterservices.usgs.gov} service calls.
Arguments to the function should be based on \url{https://waterservices.usgs.gov} service calls.
See examples below for ideas of constructing queries.
}
\examples{
......
......@@ -47,7 +47,7 @@ queryTime \tab POSIXct \tab The time the data was returned \cr
}
}
\description{
Imports data from NWIS web service. This function gets the data from here: \url{http://waterservices.usgs.gov/}
Imports data from NWIS web service. This function gets the data from here: \url{https://waterservices.usgs.gov/}
}
\examples{
siteNumber <- '04085427'
......
......@@ -8,7 +8,7 @@ readNWISpCode(parameterCd)
}
\arguments{
\item{parameterCd}{character of USGS parameter codes (or multiple parameter codes). These are 5 digit number codes,
more information can be found here: \url{http://help.waterdata.usgs.gov/}. To get a
more information can be found here: \url{https://help.waterdata.usgs.gov/}. To get a
complete list of all current parameter codes in the USGS, use "all" as the input.}
}
\value{
......@@ -25,7 +25,7 @@ parameterData data frame with the following information:
}
\description{
Imports data from NWIS about meaured parameter based on user-supplied parameter code or codes.
This function gets the data from here: \url{http://nwis.waterdata.usgs.gov/nwis/pmcodes}
This function gets the data from here: \url{https://nwis.waterdata.usgs.gov/nwis/pmcodes}
}
\examples{
paramINFO <- readNWISpCode(c('01075','00060','00931'))
......
......@@ -31,10 +31,10 @@ test_that("General NWIS retrievals working", {
# saveRDS(qwData, "rds/qwData.rds")
expect_is(qwData$startDateTime, "POSIXct")
url <- "http://waterservices.usgs.gov/nwis/dv/?site=09037500&format=rdb&ParameterCd=00060&StatCd=00003&startDT=1985-10-02&endDT=2012-09-06"
url <- "https://waterservices.usgs.gov/nwis/dv/?site=09037500&format=rdb&ParameterCd=00060&StatCd=00003&startDT=1985-10-02&endDT=2012-09-06"
dv <- importRDB1(url, asDateTime = FALSE)
urlEmpty <- "http://nwis.waterdata.usgs.gov/nwis/qwdata?multiple_site_no=413437087150601&sort_key=site_no&group_key=NONE&inventory_output=0&begin_date=&end_date=&TZoutput=0&param_group=NUT,INN&qw_attributes=0&format=rdb&qw_sample_wide=0&rdb_qw_attributes=expanded&date_format=YYYY-MM-DD&rdb_compression=value&list_of_search_criteria=multiple_site_no"
urlEmpty <- "https://nwis.waterdata.usgs.gov/nwis/qwdata?multiple_site_no=413437087150601&sort_key=site_no&group_key=NONE&inventory_output=0&begin_date=&end_date=&TZoutput=0&param_group=NUT,INN&qw_attributes=0&format=rdb&qw_sample_wide=0&rdb_qw_attributes=expanded&date_format=YYYY-MM-DD&rdb_compression=value&list_of_search_criteria=multiple_site_no"
dv <- importRDB1(urlEmpty, asDateTime = FALSE)
# saveRDS(dv, "rds/emptyDV.rds")
expect_that(nrow(dv) == 0, is_true())
......@@ -50,6 +50,12 @@ test_that("General NWIS retrievals working", {
# saveRDS(waterYearStat, "rds/waterYearStat.rds")
expect_is(waterYearStat$mean_va,"numeric")
expect_is(waterYearStat$parameter_cd,"character")
#2 data descriptors, but some random empty "values" tag:
urlTest <- "https://nwis.waterservices.usgs.gov/nwis/iv/?site=11447650&format=waterml,1.1&ParameterCd=63680&startDT=2016-12-13&endDT=2016-12-13"
x <- importWaterML1(urlTest)
expect_equal(ncol(x), 8)
})
......
......@@ -25,9 +25,7 @@ test_that("Unit value data returns correct types", {
timeZoneChange <- renameNWISColumns(timeZoneChange)
expect_is(rawData$dateTime, 'POSIXct')
expect_is(rawData$Flow_Inst, 'numeric')
# expect_that(attr(rawData, "url"), equals(
# "http://nwis.waterservices.usgs.gov/nwis/iv/?site=05114000&format=waterml,1.1&ParameterCd=00060&startDT=2014-10-10&endDT=2014-10-10")
# )
expect_equal(attr(rawData, "url"), "https://nwis.waterservices.usgs.gov/nwis/iv/?site=05114000&format=waterml,1.1&ParameterCd=00060&startDT=2014-10-10&endDT=2014-10-10")
# #First switchover to standard time:
# expect_that(as.numeric(timeZoneChange[which(timeZoneChange$tz_cd == "America/Chicago")[1],"dateTime"]),
# equals(as.numeric(as.POSIXct("2013-11-03 01:00:00", tz="UTC")+60*60*6)))
......@@ -75,7 +73,7 @@ test_that("peak, rating curves, surface-water measurements", {
emptyDF <- whatNWISdata("10312000",parameterCd = "50286")
expect_that(nrow(emptyDF) == 0, is_true())
url <- "http://waterservices.usgs.gov/nwis/site/?format=rdb&seriesCatalogOutput=true&sites=05114000"
url <- "https://waterservices.usgs.gov/nwis/site/?format=rdb&seriesCatalogOutput=true&sites=05114000"
x <- importRDB1(url)
})
......
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