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

Try again

parent 7acb0451
Package: dataRetrieval
Type: Package
Title: Retrieval Functions for USGS and EPA Hydrologic and Water Quality Data
Version: 2.7.9.0001
Version: 2.7.10
Authors@R: c(
person("Laura", "DeCicco", role = c("aut","cre"),
email = "ldecicco@usgs.gov",
......
dataRetrieval 2.8.10
==================
* Functions that come back from a server that had and error now return with a message and NULL rather than error.
dataRetrieval 2.7.9
===================
* Fix bug caused by changes in NLDI services
......
......@@ -230,7 +230,6 @@ valid_ask = function(all, type) {
#' # Find Features / Define origin features
#'
#' ## Find feature by COMID
#' if(!httr::http_error("https://labs.waterdata.usgs.gov/api/nldi/linked-data")){
#' findNLDI(comid = 101)
#'
#' ## Find feature by NWIS ID
......@@ -268,7 +267,6 @@ valid_ask = function(all, type) {
#' ## Limit search to 50 km
#' findNLDI(comid = 101, nav = "DM", find = c("nwis", "wqp", "flowlines"), distance_km = 50)
#'}
#'}
findNLDI <- function(comid = NULL,
nwis = NULL,
wqp = NULL,
......
......@@ -18,10 +18,8 @@
#' property <- '00060'
#' obs_url <- constructNWISURL(siteNumber,property,startDate,endDate,'dv')
#' \donttest{
#' if(!httr::http_error(obs_url)){
#' rawData <- getWebServiceData(obs_url)
#' }
#' }
getWebServiceData <- function(obs_url, ...){
if (!curl::has_internet()) {
......@@ -35,10 +33,12 @@ getWebServiceData <- function(obs_url, ...){
response400 <- httr::content(returnedList, type="text", encoding = "UTF-8")
statusReport <- xml_text(xml_child(read_xml(response400), 2)) # making assumption that - body is second node
statusMsg <- gsub(pattern=", server=.*", replacement="", x = statusReport)
stop(statusMsg)
message(statusMsg)
return(invisible(NULL))
} else if(httr::status_code(returnedList) != 200){
message("For: ", obs_url,"\n")
httr::stop_for_status(returnedList)
httr::message_for_status(returnedList)
return(invisible(NULL))
} else {
headerInfo <- httr::headers(returnedList)
......
......@@ -52,34 +52,33 @@
#' obs_url <- constructNWISURL(site_id,property,
#' startDate,endDate,"dv",format="tsv")
#' \donttest{
#' if(!httr::http_error(obs_url)){
#' data <- importRDB1(obs_url)
#' }
#'
#'
#' urlMultiPcodes <- constructNWISURL("04085427",c("00060","00010"),
#' startDate,endDate,"dv",statCd=c("00003","00001"),"tsv")
#' if(!httr::http_error(urlMultiPcodes)){
#'
#' multiData <- importRDB1(urlMultiPcodes)
#' }
#'
#' unitDataURL <- constructNWISURL(site_id,property,
#' "2020-10-30","2020-11-01","uv",format="tsv") #includes timezone switch
#' if(!httr::http_error(unitDataURL)){
#'
#' unitData <- importRDB1(unitDataURL, asDateTime=TRUE)
#' }
#'
#' qwURL <- constructNWISURL(c('04024430','04024000'),
#' c('34247','30234','32104','34220'),
#' "2010-11-03","","qw",format="rdb")
#' if(!httr::http_error(qwURL)){
#'
#' qwData <- importRDB1(qwURL, asDateTime=TRUE, tz="America/Chicago")
#' }
#'
#' iceSite <- '04024000'
#' start <- "2015-11-09"
#' end <- "2015-11-24"
#' urlIce <- constructNWISURL(iceSite,"00060",start, end,"uv",format="tsv")
#' if(!httr::http_error(urlIce)){
#'
#' ice <- importRDB1(urlIce, asDateTime=TRUE)
#' iceNoConvert <- importRDB1(urlIce, convertType=FALSE)
#' }
#'
#' }
#' # User file:
#' filePath <- system.file("extdata", package="dataRetrieval")
......
......@@ -22,20 +22,17 @@
#' \donttest{
#' rawSampleURL <- constructWQPURL('USGS-01594440','01075', '', '')
#'
#' if(!httr::http_error(rawSampleURL)){
#' rawSample <- importWQP(rawSampleURL)
#' }
#'
#' rawSampleURL_NoZip <- constructWQPURL('USGS-01594440','01075', '', '', zip=FALSE)
#' if(!httr::http_error(rawSampleURL_NoZip)){
#'
#' rawSample2 <- importWQP(rawSampleURL_NoZip, zip=FALSE)
#' }
#' #'
#'
#' STORETex <- constructWQPURL('WIDNR_WQX-10032762','Specific conductance', '', '')
#' if(!httr::http_error(STORETex)){
#'
#' STORETdata <- importWQP(STORETex)
#' }
#' }
#'
importWQP <- function(obs_url, zip=TRUE, tz="UTC",
csv=FALSE){
......
......@@ -56,7 +56,7 @@
#' @examples
#' \donttest{
#' # Examples not run for time considerations
#' if(!httr::http_error("https://waterservices.usgs.gov")){
#'
#' dataTemp <- readNWISdata(stateCd="OH",parameterCd="00010", service="dv")
#' instFlow <- readNWISdata(sites="05114000", service="iv",
#' parameterCd="00060",
......@@ -117,10 +117,7 @@
#' va_counties <- c("51001","51003","51005","51007","51009","51011","51013","51015")
#' va_counties_data <- readNWISdata(startDate = "2015-01-01", endDate = "2015-12-31",
#' parameterCd = "00060", countycode = va_counties)
#' }
#'
#'
#' if(!httr::http_error("https://nwis.waterdata.usgs.gov")){
#' site_id <- '01594440'
#' rating_curve <- readNWISdata(service = "rating", site_no = site_id, file_type="base")
#' all_sites_base <- readNWISdata(service = "rating", file_type="base")
......@@ -132,7 +129,7 @@
#' site_no = c("01594440","040851325"),
#' range_selection = "data_range")
#'
#' }
#'
#' }
readNWISdata <- function(..., asDateTime=TRUE,convertType=TRUE,tz="UTC"){
......
......@@ -61,10 +61,10 @@
#' @export
#' @examples
#' \donttest{
#' try({
#'
#' siteINFO <- readNWISsite('05114000')
#' siteINFOMulti <- readNWISsite(c('05114000','09423350'))
#' })
#'
#' }
readNWISsite <- function(siteNumbers){
......
......@@ -54,7 +54,7 @@
#' startDate <- "2014-10-10"
#' endDate <- "2014-10-10"
#' \donttest{
#' try({
#'
#' rawData <- readNWISuv(site_id,parameterCd,startDate,endDate)
#'
#' rawData_today <- readNWISuv(site_id, parameterCd, Sys.Date(),Sys.Date())
......@@ -69,7 +69,7 @@
#' # Adding 'Z' to the time indicates to the web service to call the data with UTC time:
#' GMTdata <- readNWISuv(site_id,parameterCd,
#' "2014-10-10T00:00Z", "2014-10-10T23:59Z")
#' })
#'
#' }
readNWISuv <- function (siteNumbers,parameterCd,startDate="",endDate="", tz="UTC"){
......
......@@ -51,7 +51,7 @@
#' @export
#' @examples
#' \donttest{
#' try({
#'
#' availableData <- whatNWISdata(siteNumber = '05114000')
#' # To find just unit value ('instantaneous') data:
#' uvData <- whatNWISdata(siteNumber = '05114000',service="uv")
......@@ -59,7 +59,7 @@
#' flowAndTemp <- whatNWISdata(stateCd = "WI", service = "uv",
#' parameterCd = c("00060","00010"),
#' statCd = "00003")
#' })
#'
#' }
whatNWISdata <- function(..., convertType=TRUE){
......
......@@ -30,10 +30,10 @@
#'
#' @examples
#' \donttest{
#' try({
#'
#' siteListPhos <- whatNWISsites(stateCd="OH",parameterCd="00665")
#' oneSite <- whatNWISsites(sites="05114000")
#' })
#'
#' }
whatNWISsites <- function(...){
......
......@@ -3,12 +3,12 @@
#' @export
#' @examples
#' \donttest{
#' try({
#'
#' site1 <- whatWQPsamples(siteid="USGS-01594440")
#'
#' type <- "Stream"
#' sites <- whatWQPsamples(countycode="US:55:025",siteType=type)
#' })
#'
#' }
whatWQPsamples <- function(...){
......
......@@ -58,14 +58,14 @@
#' @seealso whatNWISdata
#' @examples
#' \donttest{
#' try({
#'
#' site1 <- whatWQPsites(siteid="USGS-01594440")
#'
#' type <- "Stream"
#' sites <- whatWQPsites(countycode="US:55:025",
#' characteristicName = "Phosphorus",
#' siteType=type)
#' })
#'
#' }
whatWQPsites <- function(...){
......
......@@ -69,7 +69,6 @@ arguments: comid, nwis, huc12, wqp, location, and start.
# Find Features / Define origin features
## Find feature by COMID
if(!httr::http_error("https://labs.waterdata.usgs.gov/api/nldi/linked-data")){
findNLDI(comid = 101)
## Find feature by NWIS ID
......@@ -108,5 +107,4 @@ if(!httr::http_error("https://labs.waterdata.usgs.gov/api/nldi/linked-data")){
findNLDI(comid = 101, nav = "DM", find = c("nwis", "wqp", "flowlines"), distance_km = 50)
}
}
}
\keyword{nldi}
......@@ -26,8 +26,6 @@ offering <- '00003'
property <- '00060'
obs_url <- constructNWISURL(siteNumber,property,startDate,endDate,'dv')
\donttest{
if(!httr::http_error(obs_url)){
rawData <- getWebServiceData(obs_url)
}
}
}
......@@ -64,34 +64,33 @@ property <- "00060"
obs_url <- constructNWISURL(site_id,property,
startDate,endDate,"dv",format="tsv")
\donttest{
if(!httr::http_error(obs_url)){
data <- importRDB1(obs_url)
}
data <- importRDB1(obs_url)
urlMultiPcodes <- constructNWISURL("04085427",c("00060","00010"),
startDate,endDate,"dv",statCd=c("00003","00001"),"tsv")
if(!httr::http_error(urlMultiPcodes)){
multiData <- importRDB1(urlMultiPcodes)
}
unitDataURL <- constructNWISURL(site_id,property,
"2020-10-30","2020-11-01","uv",format="tsv") #includes timezone switch
if(!httr::http_error(unitDataURL)){
unitData <- importRDB1(unitDataURL, asDateTime=TRUE)
}
qwURL <- constructNWISURL(c('04024430','04024000'),
c('34247','30234','32104','34220'),
"2010-11-03","","qw",format="rdb")
if(!httr::http_error(qwURL)){
qwData <- importRDB1(qwURL, asDateTime=TRUE, tz="America/Chicago")
}
qwData <- importRDB1(qwURL, asDateTime=TRUE, tz="America/Chicago")
iceSite <- '04024000'
start <- "2015-11-09"
end <- "2015-11-24"
urlIce <- constructNWISURL(iceSite,"00060",start, end,"uv",format="tsv")
if(!httr::http_error(urlIce)){
ice <- importRDB1(urlIce, asDateTime=TRUE)
iceNoConvert <- importRDB1(urlIce, convertType=FALSE)
}
}
# User file:
filePath <- system.file("extdata", package="dataRetrieval")
......
......@@ -32,20 +32,17 @@ Imports data from the Water Quality Portal based on a specified url.
\donttest{
rawSampleURL <- constructWQPURL('USGS-01594440','01075', '', '')
if(!httr::http_error(rawSampleURL)){
rawSample <- importWQP(rawSampleURL)
}
rawSample <- importWQP(rawSampleURL)
rawSampleURL_NoZip <- constructWQPURL('USGS-01594440','01075', '', '', zip=FALSE)
if(!httr::http_error(rawSampleURL_NoZip)){
rawSample2 <- importWQP(rawSampleURL_NoZip, zip=FALSE)
}
#'
rawSample2 <- importWQP(rawSampleURL_NoZip, zip=FALSE)
STORETex <- constructWQPURL('WIDNR_WQX-10032762','Specific conductance', '', '')
if(!httr::http_error(STORETex)){
STORETdata <- importWQP(STORETex)
}
}
}
\seealso{
\code{\link{readWQPdata}}, \code{\link{readWQPqw}}, \code{\link{whatWQPsites}}
......
......@@ -67,7 +67,7 @@ See examples below for ideas of constructing queries.
\examples{
\donttest{
# Examples not run for time considerations
if(!httr::http_error("https://waterservices.usgs.gov")){
dataTemp <- readNWISdata(stateCd="OH",parameterCd="00010", service="dv")
instFlow <- readNWISdata(sites="05114000", service="iv",
parameterCd="00060",
......@@ -128,10 +128,7 @@ dailyStaffordVA <- readNWISdata(stateCd = "Virginia",
va_counties <- c("51001","51003","51005","51007","51009","51011","51013","51015")
va_counties_data <- readNWISdata(startDate = "2015-01-01", endDate = "2015-12-31",
parameterCd = "00060", countycode = va_counties)
}
if(!httr::http_error("https://nwis.waterdata.usgs.gov")){
site_id <- '01594440'
rating_curve <- readNWISdata(service = "rating", site_no = site_id, file_type="base")
all_sites_base <- readNWISdata(service = "rating", file_type="base")
......@@ -143,7 +140,7 @@ peak_data <- readNWISdata(service = "peak",
site_no = c("01594440","040851325"),
range_selection = "data_range")
}
}
}
\seealso{
......
......@@ -70,10 +70,10 @@ Imports data from USGS site file site. This function gets data from here: \url{h
}
\examples{
\donttest{
try({
siteINFO <- readNWISsite('05114000')
siteINFOMulti <- readNWISsite(c('05114000','09423350'))
})
}
}
\keyword{USGS}
......
......@@ -65,7 +65,7 @@ parameterCd <- '00060'
startDate <- "2014-10-10"
endDate <- "2014-10-10"
\donttest{
try({
rawData <- readNWISuv(site_id,parameterCd,startDate,endDate)
rawData_today <- readNWISuv(site_id, parameterCd, Sys.Date(),Sys.Date())
......@@ -80,7 +80,7 @@ centralTime <- readNWISuv(site_id,parameterCd,
# Adding 'Z' to the time indicates to the web service to call the data with UTC time:
GMTdata <- readNWISuv(site_id,parameterCd,
"2014-10-10T00:00Z", "2014-10-10T23:59Z")
})
}
}
\seealso{
......
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