Commit 05cb7add authored by Laura A DeCicco's avatar Laura A DeCicco
Browse files

Use setAccess for WQP too

parent df177ebe
......@@ -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)
......@@ -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)
......
......@@ -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)
}
......
#' 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")
......
......@@ -23,9 +23,7 @@ retrieval for the latest possible record.}
url string
}
\description{
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}
}
\examples{
siteNumber <- '01594440'
......
......@@ -11,7 +11,7 @@ readWQPdata(..., zip = FALSE, querySummary = FALSE)
\item{querySummary}{logical to ONLY return the number of records and unique sites that will be returned from this query.}
\item{\dots}{see \url{www.waterqualitydata.us/webservices_documentation.jsp} for a complete list of options}
\item{\dots}{see \url{https://www.waterqualitydata.us/webservices_documentation} for a complete list of options}
}
\value{
A data frame with at least the following columns:
......
......@@ -9,7 +9,7 @@ whatWQPsites(..., zip = FALSE)
\arguments{
\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}
\item{\dots}{see \url{https://www.waterqualitydata.us/webservices_documentation} for a complete list of options}
}
\value{
A data frame with at least the following columns:
......@@ -55,8 +55,8 @@ queryTime \tab POSIXct \tab Query time \cr
* element is only in NWIS
}
\description{
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}
}
\examples{
\dontrun{
......
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