Skip to content
Snippets Groups Projects
Commit f3eaae4b authored by Laura A DeCicco's avatar Laura A DeCicco
Browse files

Added pcode check.

parent 6d4c29f1
No related branches found
No related tags found
1 merge request!39Overhaul of function names. Move some functionality to EGRET.
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
#' "gw"(groundwater levels), "ad" (sites included in USGS Annual Water Data Reports External Link), #' "gw"(groundwater levels), "ad" (sites included in USGS Annual Water Data Reports External Link),
#' "aw" (sites monitored by the USGS Active Groundwater Level Network External Link), "id" (historical #' "aw" (sites monitored by the USGS Active Groundwater Level Network External Link), "id" (historical
#' instantaneous values), " #' instantaneous values), "
#' @param pCode string #' @param pCode string vector
#' @keywords data import USGS web service #' @keywords data import USGS web service
#' @return retval dataframe with all information found in the expanded site file #' @return retval dataframe with all information found in the expanded site file
#' @export #' @export
...@@ -29,6 +29,21 @@ whatNWISdata <- function(siteNumbers,service="all",pCode="all",statCd="all"){ ...@@ -29,6 +29,21 @@ whatNWISdata <- function(siteNumbers,service="all",pCode="all",statCd="all"){
service <- match.arg(service, c("dv","uv","qw","ad","id","pk","sv","gw","aw","all","ad","iv","rt"), several.ok = TRUE) service <- match.arg(service, c("dv","uv","qw","ad","id","pk","sv","gw","aw","all","ad","iv","rt"), several.ok = TRUE)
} }
if(!("all" %in% pCode){
pcodeCheck <- all(nchar(pCode) == 5) & all(!is.na(suppressWarnings(as.numeric(pCode))))
if(!pcodeCheck){
goodIndex <- which(pCode %in% parameterCdFile$parameter_cd)
if(length(goodIndex) > 0){
badPcode <- pCode[-goodIndex]
} else {
badPcode <- pCode
}
message("The following pCodes seem mistyped:",paste(badPcode,collapse=","), "and will be ignored.")
pCode <- pCode[goodIndex]
}
}
urlSitefile <- paste("http://waterservices.usgs.gov/nwis/site/?format=rdb&seriesCatalogOutput=true&sites=",siteNumber,sep = "") urlSitefile <- paste("http://waterservices.usgs.gov/nwis/site/?format=rdb&seriesCatalogOutput=true&sites=",siteNumber,sep = "")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment