Commit 18d5f139 authored by Laura A DeCicco's avatar Laura A DeCicco Committed by GitHub
Browse files

Merge pull request #294 from ldecicco-USGS/master

https stuff
parents 9b63afb0 d5747f4b
Package: dataRetrieval
Type: Package
Title: Retrieval Functions for USGS and EPA Hydrologic and Water Quality Data
Version: 2.6.4
Date: 2016-12-12
Version: 2.6.5
Date: 2016-12-14
Authors@R: c( person("Robert", "Hirsch", role = c("aut"),
email = "rhirsch@usgs.gov"),
person("Laura", "DeCicco", role = c("aut","cre"),
......
#' 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
......@@ -257,9 +257,7 @@ constructNWISURL <- function(siteNumber,parameterCd="00060",startDate="",endDate
#' Construct WQP url for data retrieval
#'
#' Imports data from WQP 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}
#' Construct WQP url for data retrieval. This function gets the data from here: \url{https://www.waterqualitydata.us}
#'
#' @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.
......@@ -296,9 +294,8 @@ constructWQPURL <- function(siteNumber,parameterCd,startDate,endDate,zip=FALSE){
parameterCd <- paste(parameterCd, collapse=";")
}
baseURL <- "http://www.waterqualitydata.us/Result/search?siteid="
baseURL <- drURL("wqpData", siteid = siteNumber)
url <- paste0(baseURL,
siteNumber,
ifelse(pCodeLogic,"&pCode=","&characteristicName="),
parameterCd)
......@@ -324,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)
......@@ -336,21 +333,23 @@ constructWQPURL <- function(siteNumber,parameterCd,startDate,endDate,zip=FALSE){
#' url <- constructUseURL(years=c(1990,1995),stateCd="Ohio",countyCd = c(1,3), categories = "ALL")
#'
constructUseURL <- function(years,stateCd,countyCd,categories){
baseURL <- "http://waterdata.usgs.gov/"
base2 <- "nwis/water_use?format=rdb&rdb_compression=value"
if(is.null(stateCd)){
baseURL <- paste0(baseURL,base2)
} else{
baseURL <- drURL("useNat", format="rdb", rdb_compression="value")
} else {
stateCd <- stateCdLookup(input = stateCd, outputType = "postal")
baseURL <- "https://waterdata.usgs.gov/"
base2 <- "nwis/water_use?format=rdb&rdb_compression=value"
baseURL <- paste0(baseURL,paste0(stateCd,"/"),base2)
if(!is.null(countyCd)){
if(length(countyCd) > 1) {countyCd <- paste(countyCd,collapse="%2C")}
baseURL <- paste0(baseURL,"&wu_area=county&wu_county=",countyCd)
} else{
baseURL <- paste0(baseURL,"&wu_area=State%20Total")
}
} else {
baseURL <- paste0(baseURL,"&wu_area=State%20Total")
}
}
years <- paste(years, collapse="%2C")
categories <- paste(categories, collapse = "%2C")
retURL <- paste0(baseURL,"&wu_year=",years,"&wu_category=",categories)
......
......@@ -52,7 +52,7 @@ getWebServiceData <- function(obs_url, ...){
if(headerInfo$`content-type` == "text/tab-separated-values;charset=UTF-8"){
returnedDoc <- content(returnedList, type="text",encoding = "UTF-8")
} else if (headerInfo$`content-type` == "text/html"){
} else if (headerInfo$`content-type` %in% c("text/html","text/html; charset=UTF-8") ){
txt <- readBin(returnedList$content, character())
message(txt)
return(txt)
......
......@@ -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
......
......@@ -156,7 +156,7 @@ importWaterML1 <- function(obs_url,asDateTime=FALSE, tz=""){
obsDF <- NULL
useMethodDesc <- FALSE
if(length(valParents) > 1){ useMethodDesc <- TRUE} #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")
......@@ -186,6 +186,7 @@ importWaterML1 <- function(obs_url,asDateTime=FALSE, tz=""){
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))){
......@@ -196,8 +197,8 @@ importWaterML1 <- function(obs_url,asDateTime=FALSE, tz=""){
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)
"%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",""),
......@@ -245,15 +246,17 @@ importWaterML1 <- function(obs_url,asDateTime=FALSE, tz=""){
}
}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
# but don't overwrite:
if(is.null(obsDF)){
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(is.null(obsDF)){
mergedSite <- data.frame()
next
......
......@@ -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,]
}
......
#' Raw Data Import for USGS NWIS QW Data
#'
#' 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}
#'
#' @details Valid parameter code groups are "All," or group codes:
#'\tabular{ll}{
......@@ -106,7 +106,7 @@ readNWISqw <- function (siteNumbers,parameterCd,startDate="",endDate="",
if(any(parameterCd == "all") | any(parameterCd == "All") ){
siteNumbers <- paste(siteNumbers, collapse=",")
url <- paste0("http://nwis.waterdata.usgs.gov/nwis/qwdata?multiple_site_no=", siteNumbers,
url <- paste0("https://nwis.waterdata.usgs.gov/nwis/qwdata?multiple_site_no=", siteNumbers,
"&sort_key=site_no&group_key=NONE&inventory_output=0",
"&begin_date=", startDate, "&end_date=", endDate,
"&TZoutput=0",
......@@ -116,7 +116,7 @@ readNWISqw <- function (siteNumbers,parameterCd,startDate="",endDate="",
} else if (all(parameterCd %in% pgrp)){
siteNumbers <- paste(siteNumbers, collapse=",")
groups <- paste(parameterCd, collapse=",")
url <- paste0("http://nwis.waterdata.usgs.gov/nwis/qwdata?multiple_site_no=", siteNumbers,
url <- paste0("https://nwis.waterdata.usgs.gov/nwis/qwdata?multiple_site_no=", siteNumbers,
"&sort_key=site_no&group_key=NONE&inventory_output=0",
"&begin_date=", startDate, "&end_date=", endDate,
"&TZoutput=0&param_group=", groups,
......
#' USGS Site File Data Retrieval
#'
#' Imports data from USGS site file site. This function gets data from here: \url{http://waterservices.usgs.gov/}
#' Imports data from USGS site file site. This function gets data from here: \url{https://waterservices.usgs.gov/}
#'
#' @param siteNumbers character USGS site number (or multiple sites). This is usually an 8 digit number
#' @keywords data import USGS web service
......
#' Instantaneous value data retrieval from USGS (NWIS)
#'
#' Imports data from NWIS web service. This function gets the data from here: \url{http://waterservices.usgs.gov/}
#' 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}.
#' More information on the web service can be found here: \url{http://waterservices.usgs.gov/rest/IV-Service.html}.
#' Imports data from NWIS web service. This function gets the data from here: \url{https://waterservices.usgs.gov/}
#' 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}.
#' More information on the web service can be found here: \url{https://waterservices.usgs.gov/rest/IV-Service.html}.
#'
#' @param siteNumbers character USGS site number (or multiple sites). This is usually an 8 digit number
#' @param parameterCd character USGS parameter code. This is usually an 5 digit number.
#' @param startDate character starting date for data retrieval in the form YYYY-MM-DD. Default is "" which indicates
#' retrieval for the earliest possible record. Simple date arguments are specified in local time.
#' See more information here: \url{http://waterservices.usgs.gov/rest/IV-Service.html#Specifying}.
#' See more information here: \url{https://waterservices.usgs.gov/rest/IV-Service.html#Specifying}.
#' @param endDate character ending date for data retrieval in the form YYYY-MM-DD. Default is "" which indicates
#' retrieval for the latest possible record. Simple date arguments are specified in local time.
#' See more information here: \url{http://waterservices.usgs.gov/rest/IV-Service.html#Specifying}.
#' See more information here: \url{https://waterservices.usgs.gov/rest/IV-Service.html#Specifying}.
#' @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",
......@@ -77,7 +77,7 @@ readNWISuv <- function (siteNumbers,parameterCd,startDate="",endDate="", tz=""){
#' Peak flow data from USGS (NWIS)
#'
#' Reads peak flow from NWISweb. Data is retrieved from \url{http://waterdata.usgs.gov/nwis}.
#' Reads peak flow from NWISweb. Data is retrieved from \url{https://waterdata.usgs.gov/nwis}.
#' In some cases, the specific date of the peak data is not know. This function will default to
#' converting the complete dates, dropping rows with incomplete dates. If those incomplete dates are
#' needed, set the `asDateTime` argument to FALSE. No rows will be removed, and no dates will be converted
......@@ -167,7 +167,7 @@ readNWISpeak <- function (siteNumbers,startDate="",endDate="", asDateTime=TRUE,
#' Rating table for an active USGS streamgage retrieval
#'
#' Reads current rating table for an active USGS streamgage from NWISweb.
#' Data is retrieved from \url{http://waterdata.usgs.gov/nwis}.
#' Data is retrieved from \url{https://waterdata.usgs.gov/nwis}.
#'
#' @param siteNumber character USGS site number. This is usually an 8 digit number
#' @param type character can be "base", "corr", or "exsa"
......@@ -236,8 +236,8 @@ readNWISrating <- function (siteNumber,type="base",convertType = TRUE){
#'Surface-water measurement data retrieval from USGS (NWIS)
#'
#'Reads surface-water measurement data from NWISweb. Data is retrieved from \url{http://waterdata.usgs.gov/nwis}.
#'See \url{http://waterdata.usgs.gov/usa/nwis/sw} for details about surface water.
#'Reads surface-water measurement data from NWISweb. Data is retrieved from \url{https://waterdata.usgs.gov/nwis}.
#'See \url{https://waterdata.usgs.gov/usa/nwis/sw} for details about surface water.
#'
#' @param siteNumbers character USGS site number (or multiple sites). This is usually an 8 digit number
#' @param startDate character starting date for data retrieval in the form YYYY-MM-DD. Default is "" which indicates
......@@ -262,8 +262,8 @@ readNWISrating <- function (siteNumber,type="base",convertType = TRUE){
#' tz_cd \tab character \tab The time zone code for the measurement_dt column \cr
#' }
#'
#' See \url{http://waterdata.usgs.gov/usa/nwis/sw} for details about surface water, and
#' \url{http://waterdata.usgs.gov/nwis/help?output_formats_help#streamflow_measurement_data}
#' See \url{https://waterdata.usgs.gov/usa/nwis/sw} for details about surface water, and
#' \url{https://waterdata.usgs.gov/nwis/help?output_formats_help#streamflow_measurement_data}
#' for help on the columns and codes.
#'
#' There are also several useful attributes attached to the data frame:
......@@ -338,10 +338,10 @@ readNWISmeas <- function (siteNumbers,startDate="",endDate="", tz="", expanded=F
#' Groundwater level measurements retrieval from USGS (NWIS)
#'
#' Reads groundwater level measurements from NWISweb. Mixed date/times come back from the service
#' depending on the year that the data was collected. See \url{http://waterdata.usgs.gov/usa/nwis/gw}
#' depending on the year that the data was collected. See \url{https://waterdata.usgs.gov/usa/nwis/gw}
#' for details about groundwater. By default the returned dates are converted to date objects, unless convertType
#' is specified as FALSE. Sites with non-standard date formats (i.e. lacking a day) can be affected (see examples).
#' See \url{http://waterservices.usgs.gov/rest/GW-Levels-Service.html} for more information.
#' See \url{https://waterservices.usgs.gov/rest/GW-Levels-Service.html} for more information.
#'
#' @param siteNumbers character USGS site number (or multiple sites). This is usually an 8 digit number
#' @param startDate character starting date for data retrieval in the form YYYY-MM-DD. Default is "" which indicates
......@@ -417,7 +417,7 @@ readNWISgwl <- function (siteNumbers,startDate="",endDate="", convertType = TRUE
#' Site statistics retrieval from USGS (NWIS)
#'
#' Retrieves site statistics from the USGS Statistics Web Service beta.
#' See \url{http://waterservices.usgs.gov/rest/Statistics-Service.html} for more information.
#' See \url{https://waterservices.usgs.gov/rest/Statistics-Service.html} for more information.
#'
#' @param siteNumbers character USGS site number (or multiple sites). This is usually an 8 digit number.
#' @param parameterCd character USGS parameter code. This is usually a 5 digit number.
......@@ -439,7 +439,7 @@ readNWISgwl <- function (siteNumbers,startDate="",endDate="", convertType = TRUE
#' provide statistics for each month and year within the range indivually.
#' @param statType character 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.
#' @return A data frame with the following columns:
#' \tabular{lll}{
#' Name \tab Type \tab Description \cr
......@@ -495,7 +495,7 @@ readNWISstat <- function(siteNumbers, parameterCd, startDate = "", endDate = "",
#' Water use data retrieval from USGS (NWIS)
#'
#' Retrieves water use data from USGS Water Use Data for the Nation. See \url{http://waterdata.usgs.gov/nwis/wu} for
#' Retrieves water use data from USGS Water Use Data for the Nation. See \url{https://waterdata.usgs.gov/nwis/wu} for
#' more information. All available use categories for the supplied arguments are retrieved.
#'
#' @param stateCd could be character (full name, abbreviation, id), or numeric (id). Only one is accepted per query.
......
......@@ -3,7 +3,7 @@
#' Imports data from Water Quality Portal web service. This function gets the data from here: \url{https://www.waterqualitydata.us}.
#' 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 \dots see \url{https://www.waterqualitydata.us/webservices_documentation} for a complete list of options
#' @param zip logical to request data via downloading zip file. Default set to FALSE.
#' @param querySummary logical to ONLY return the number of records and unique sites that will be returned from this query.
#' @keywords data import WQP web service
......@@ -149,7 +149,7 @@ readWQPdata <- function(..., zip=FALSE, querySummary=FALSE){
urlCall <- paste(paste(names(values),values,sep="="),collapse="&")
baseURL <- "https://www.waterqualitydata.us/Result/search?"
baseURL <- drURL("wqpData")
urlCall <- paste0(baseURL,
urlCall,
"&sorted=no&mimeType=tsv")
......
......@@ -49,7 +49,12 @@ access = match.arg(access, c('public','internal','cooperator','USGS'))
pkg.env$rating = "https://waterdata.usgs.gov/nwisweb/get_ratings/"
pkg.env$qwdata = "https://nwis.waterdata.usgs.gov/nwis/qwdata"
pkg.env$stat = "https://waterservices.usgs.gov/nwis/stat/"
pkg.env$useNat = "https://waterdata.usgs.gov/nwis/water_use"
# NOTE: state water use are still in: constructUseURL
pkg.env$wqpData = "https://www.waterqualitydata.us/Result/search"
pkg.env$wqpStation = "https://www.waterqualitydata.us/Station/search"
options(Access.dataRetrieval = access)
}
......
......@@ -14,24 +14,24 @@
#' that originally came from the United States Geological Survey, an agency of
#' the United States Department of Interior. For more information, see the
#' official USGS copyright policy at
#' http://www.usgs.gov/visual-id/credit_usgs.html#copyright\cr
#' https://www.usgs.gov/visual-id/credit_usgs.html#copyright\cr
#' LazyLoad: \tab yes\cr
#' }
#'
#' Retrieval functions for USGS and EPA hydrologic and water quality data.
#'
#' Please see \url{http://pubs.usgs.gov/tm/04/a10/} for more information.
#' Please see \url{https://pubs.usgs.gov/tm/04/a10/} for more information.
#'
#' @name dataRetrieval-package
#' @docType package
#' @author Robert M. Hirsch \email{rhirsch@@usgs.gov}, Laura De Cicco \email{ldecicco@@usgs.gov}
#' @author Laura De Cicco \email{ldecicco@@usgs.gov}
#' @keywords USGS, web services
NULL
#' List of USGS parameter codes
#'
#' Complete list of USGS parameter codes as of November 7, 2014. The data was pulled from
#' \url{http://nwis.waterdata.usgs.gov/nwis/pmcodes/pmcodes?radio_pm_search=param_group&pm_group=All+--+include+all+parameter+groups&
#' \url{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}
#'
#' @name parameterCdFile
......@@ -58,7 +58,7 @@ NULL
#' Data to convert USGS parameter code to characteristic names
#'
#' Data pulled from Water Quality Portal on November 25, 2014. The data was pulled from
#' \url{http://www.waterqualitydata.us/public_srsnames?mimeType=json}.
#' \url{https://www.waterqualitydata.us/public_srsnames?mimeType=json}.
#'
#' @name pCodeToName
#' @return pCodeToName data frame with information about USGS parameters and how they
......@@ -87,7 +87,7 @@ NULL
#' US State Code Lookup Table
#'
#' Data pulled from \url{http://www2.census.gov/geo/docs/reference/state.txt}
#' Data pulled from \url{https://www2.census.gov/geo/docs/reference/state.txt}
#' on April 1, 2015.
#'
#' @name stateCd
......@@ -109,7 +109,7 @@ NULL
#' US County Code Lookup Table
#'
#' Data pulled from \url{http://www2.census.gov/geo/docs/reference/codes/files/national_county.txt}
#' Data pulled from \url{https://www2.census.gov/geo/docs/reference/codes/files/national_county.txt}
#' on April 1, 2015.
#'
#' @name countyCd
......
#' USGS data availability
#'
#' Imports a table of available parameters, period of record, and count. See \url{http://waterservices.usgs.gov/rest/Site-Service.html}
#' Imports a table of available parameters, period of record, and count. See \url{https://waterservices.usgs.gov/rest/Site-Service.html}
#' for more information.
#'
#' @param siteNumbers character USGS site number or multiple sites.
......
#' Site Data Import from NWIS
#'
#' Returns a list of sites from the NWIS web service. This function gets the data from: \url{http://waterservices.usgs.gov/rest/Site-Test-Tool.html}.
#' Arguments to the function should be based on \url{http://waterservices.usgs.gov/rest/Site-Service.html#Service}
#' Returns a list of sites from the NWIS web service. This function gets the data from: \url{https://waterservices.usgs.gov/rest/Site-Test-Tool.html}.
#' Arguments to the function should be based on \url{https://waterservices.usgs.gov/rest/Site-Service.html#Service}
#' Mapper format is used
#'
#' @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
#' @return A data frame with at least the following columns:
#' \tabular{lll}{
......
#' Site Data Import from Water Quality Portal
#'
#' Returns a list of sites from the Water Quality Portal web service. This function gets the data from: \url{http://www.waterqualitydata.us}.
#' Arguments to the function should be based on \url{www.waterqualitydata.us/webservices_documentation.jsp}
#' Returns a list of sites from the Water Quality Portal web service. This function gets the data from: \url{https://www.waterqualitydata.us}.
#' Arguments to the function should be based on \url{https://www.waterqualitydata.us/webservices_documentation}
#'
#' @param \dots see \url{www.waterqualitydata.us/webservices_documentation.jsp} for a complete list of options
#' @param \dots see \url{https://www.waterqualitydata.us/webservices_documentation} for a complete list of options
#' @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:
......@@ -94,7 +94,7 @@ whatWQPsites <- function(...,zip=FALSE){
urlCall <- paste(paste(names(values),values,sep="="),collapse="&")
baseURL <- "http://www.waterqualitydata.us/Station/search?"
baseURL <- drURL("wqpStation")
urlCall <- paste0(baseURL,
urlCall,
"&mimeType=tsv&sorted=no")
......
......@@ -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")
......
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