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

Merge pull request #2 from ldecicco-USGS/master

Updating naming convention + other minor changes.
parents c7fc14fb 362b2488
No related branches found
No related tags found
No related merge requests found
Package: dataRetrieval
Type: Package
Title: Retrieval functions for hydrologic data
Version: 1.3.1
Date: 2014-07-01
Version: 1.3.2
Date: 2014-08-04
Author: Robert M. Hirsch, Laura De Cicco
Maintainer: Laura De Cicco <ldecicco@usgs.gov>
Description: Collection of functions to help retrieve USGS data from either web
......
......@@ -15,10 +15,8 @@ export(getDataFromFile)
export(getGeneralWQPData)
export(getMetaData)
export(getParameterInfo)
export(getQWData)
export(getQWDataFromFile)
export(getRDB1Data)
export(getRawQWData)
export(getSTORETSampleData)
export(getSampleData)
export(getSampleDataFromFile)
......@@ -38,9 +36,10 @@ export(populateSiteINFO)
export(processQWData)
export(removeDuplicates)
export(renameColumns)
export(retrieveNWISData)
export(retrieveNWISdvData)
export(retrieveNWISqwData)
export(retrieveUnitNWISData)
export(retrieveNWISunitData)
export(retrieveWQPqwData)
import(RCurl)
import(XML)
import(reshape2)
......
dataRetrieval 1.3.2
===========
* Deprecated getQWData, updated getWQPData to take either parameter code or characteristic name.
* Changed the name of raw data retrievals to: retrieveNWISqwData, retrieveNWISunitData, retrieveNWISdvData, and retrieveWQPqwData (from: retrieveNWISqwData, retrieveUnitNWISData, retrieveNWISData, getRawQWData)
* Added NA warning to getDVData function
dataRetrieval 1.2.2
===========
......
......@@ -27,7 +27,7 @@
#' url_unit <- constructNWISURL(siteNumber,pCode,"2012-06-28","2012-06-30",'iv')
#' url_qw_single <- constructNWISURL(siteNumber,"01075",startDate,endDate,'qw')
#' url_qw <- constructNWISURL(siteNumber,c('01075','00029','00453'),startDate,endDate,'qw')
#' url_wqp <- constructNWISURL(siteNumber,c('01075','00029','00453'),startDate,endDate,'wqp')
#' url_wqp <- constructNWISURL(paste("USGS",siteNumber,sep="-"),c('01075','00029','00453'),startDate,endDate,'wqp')
#' url_daily_tsv <- constructNWISURL(siteNumber,pCode,startDate,endDate,'dv',statCd=c("00003","00001"),format="tsv")
constructNWISURL <- function(siteNumber,parameterCd,startDate,endDate,service,statCd="00003", format="xml",expanded=FALSE,interactive=TRUE){
......@@ -87,6 +87,14 @@ constructNWISURL <- function(siteNumber,parameterCd,startDate,endDate,service,st
wqp = {
siteNumber <- formatCheckSiteNumber(siteNumber, interactive=interactive)
#Check for pcode:
if(all(nchar(parameterCd) == 5)){
suppressWarnings(pCodeLogic <- all(!is.na(as.numeric(parameterCd))))
} else {
pCodeLogic <- FALSE
parameterCd <- URLencode(parameterCd)
}
if(length(parameterCd)>1){
parameterCd <- paste(parameterCd, collapse=";")
}
......@@ -98,10 +106,10 @@ constructNWISURL <- function(siteNumber,parameterCd,startDate,endDate,service,st
endDate <- format(as.Date(endDate), format="%m-%d-%Y")
}
baseURL <- "http://www.waterqualitydata.us/Result/search?siteid=USGS-"
baseURL <- "http://www.waterqualitydata.us/Result/search?siteid="
url <- paste(baseURL,
siteNumber,
"&pCode=",
ifelse(pCodeLogic,"&pCode=","&characteristicName="),
parameterCd,
"&startDateLo=",
startDate,
......
......@@ -18,14 +18,14 @@
#' @keywords data import USGS WRTDS
#' @export
#' @return Daily dataframe
#' @seealso \code{\link{retrieveNWISData}}, \code{\link{populateDaily}}
#' @seealso \code{\link{retrieveNWISdvData}}, \code{\link{populateDaily}}
#' @examples
#' # These examples require an internet connection to run
#' Daily <- getDVData('01594440','00060', '1985-01-01', '1985-03-31')
#' DailyCFS <- getDVData('01594440','00060', '1985-01-01', '1985-03-31',convert=FALSE)
#' DailySuspSediment <- getDVData('01594440','80154', '1985-01-01', '1985-03-31')
getDVData <- function (siteNumber,ParameterCd,StartDate,EndDate,interactive=TRUE,convert=TRUE,format="tsv"){
data <- retrieveNWISData(siteNumber,ParameterCd,StartDate,EndDate,interactive=interactive,format=format)
data <- retrieveNWISdvData(siteNumber,ParameterCd,StartDate,EndDate,interactive=interactive,format=format)
# need to setup conversion factor because the NWIS data are in cfs but we store in cms
names(data) <- c('agency', 'site', 'dateTime', 'value', 'code') # do a merge instead?
......
#' Data Import for USGS NWIS Water Quality Data
#'
#' Imports and processes data from NWIS web service. This function gets the data from here: \url{http://www.waterqualitydata.us}
#' 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}
#'
#' @param siteNumber string USGS site number. This is usually an 8 digit number
#' @param ParameterCd string USGS parameter code. This is usually an 5 digit number. Multiple parameter codes can be inputted with a ';' separator. Leaving this blank will return all of the measured values during the specified time period.
#' @param StartDate string starting date for data retrieval in the form YYYY-MM-DD.
#' @param EndDate string ending date for data retrieval in the form YYYY-MM-DD.
#' @param interactive logical Option for interactive mode. If true, there is user interaction for error handling and data checks.
#' @keywords data import USGS web service
#' @return retval dataframe with first column dateTime, and at least one qualifier and value columns
#' (subsequent qualifier/value columns could follow depending on requested parameter codes)
#' @export
#' @examples
#' # These examples require an internet connection to run
#' rawProcessedSample <- getQWData('01594440','01075', '1985-01-01', '1985-03-31')
#' rawProcessedSampleAll <- getQWData('05114000','', '1985-01-01', '1985-03-31')
#' rawProcessedSampleSelect <- getQWData('05114000','00915;00931', '1985-01-01', '1985-04-30')
getQWData <- function(siteNumber,ParameterCd,StartDate,EndDate,interactive=TRUE){
rawSample <- getRawQWData(siteNumber,ParameterCd,StartDate,EndDate,interactive)
retval <- processQWData(rawSample)
return(retval)
}
......@@ -16,20 +16,25 @@
#' @import RCurl
#' @examples
#' # These examples require an internet connection to run
#' rawSample <- getRawQWData('01594440','01075', '1985-01-01', '1985-03-31')
#' rawSampleAll <- getRawQWData('05114000','', '1985-01-01', '1985-03-31')
#' rawSampleSelect <- getRawQWData('05114000',c('00915','00931'), '1985-01-01', '1985-04-30')
getRawQWData <- function(siteNumber,ParameterCd,StartDate,EndDate,interactive=TRUE){
#' rawSample <- retrieveWQPqwData('USGS-01594440','01075', '1985-01-01', '1985-03-31')
#' rawSampleAll <- retrieveWQPqwData('USGS-05114000','', '1985-01-01', '1985-03-31')
#' rawSampleSelect <- retrieveWQPqwData('USGS-05114000',c('00915','00931'), '1985-01-01', '1985-04-30')
#' rawStoret <- retrieveWQPqwData('WIDNR_WQX-10032762','Specific conductance', '', '')
retrieveWQPqwData <- function(siteNumber,ParameterCd,StartDate,EndDate,interactive=TRUE){
url <- constructNWISURL(siteNumber,ParameterCd,StartDate,EndDate,"wqp",interactive=interactive)
# require(RCurl)
h <- basicHeaderGatherer()
doc <- getURI(url, headerfunction = h$update)
numToBeReturned <- as.numeric(h$value()["Total-Result-Count"])
suppressWarnings(retval <- read.delim(url, header = TRUE, quote="\"", dec=".", sep='\t', colClasses=c('character'), fill = TRUE))
actualNumReturned <- nrow(retval)
if(actualNumReturned != numToBeReturned) warning(numToBeReturned, " sample results were expected, ", actualNumReturned, " were returned")
return(retval)
if (!is.na(numToBeReturned) | numToBeReturned != 0){
suppressWarnings(retval <- read.delim(url, header = TRUE, quote="\"", dec=".", sep='\t', colClasses=c('character'), fill = TRUE))
actualNumReturned <- nrow(retval)
if(actualNumReturned != numToBeReturned) warning(numToBeReturned, " sample results were expected, ", actualNumReturned, " were returned")
return(retval)
} else {
warning("No data to retrieve")
}
}
#' Import Sample Data for WRTDS
#'
#' Imports data from NWIS web service. This function gets the data from here: \url{http://qwwebservices.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}
#' For raw data, use getQWData. This function will retrieve the raw data, and compress it (summing constituents). See
#' chapter 7 of the EGRET user guide for more details.
#' Imports data from the Water Quality Portal. This function gets the data from: \url{http://www.waterqualitydata.us}
#' For raw data, use getWQPData. This function will retrieve the raw data, and compress it (summing constituents). See
#' chapter 7 of the EGRET user guide for more details, then converts it to the Sample dataframe structure.
#'
#' @param siteNumber string site number. If USGS, it should be in the form :'USGS-XXXXXXXXX...'
#' @param characteristicName string
......
#' Data Import from Water Quality Portal
#'
#' Imports data from Water Quality Portal web service. This function gets the data from here: \url{http://www.waterqualitydata.us}. This function is more general than getQWData
#' Imports data from Water Quality Portal web service. This function gets the data from: \url{http://www.waterqualitydata.us}. This function is more general than getQWData
#' because it allows for other agencies rather than the USGS. Therefore, the 5-digit parameter code cannot be used.
#' Instead, this function uses characteristicName. A complete list can be found here \url{http://www.waterqualitydata.us/Codes/Characteristicname}
#' Instead, this function uses characteristicName. A complete list can be found here
#'
#' @param siteNumber string site number. If USGS, it should be in the form :'USGS-XXXXXXXXX...'
#' @param characteristicName string
......@@ -16,77 +16,30 @@
#' @import RCurl
#' @examples
#' # These examples require an internet connection to run
#' getWQPData('USGS-01594440','Chloride', '', '')
#' getWQPData('WIDNR_WQX-10032762','Specific conductance', '', '')
#' Chloride <- getWQPData('USGS-01594440','Chloride', '', '')
#' SC <- getWQPData('WIDNR_WQX-10032762','Specific conductance', '', '')
#' NWIS_Cl <- getWQPData('USGS-04024000','30234', '', '')
#' MultipleQW <- getWQPData('USGS-04024000',c('30234','90095'), '', '')
getWQPData <- function(siteNumber,characteristicName,StartDate,EndDate,interactive=TRUE){
# require(RCurl)
StartDate <- formatCheckDate(StartDate, "StartDate", interactive=interactive)
EndDate <- formatCheckDate(EndDate, "EndDate", interactive=interactive)
dateReturn <- checkStartEndDate(StartDate, EndDate, interactive=interactive)
StartDate <- dateReturn[1]
EndDate <- dateReturn[2]
if (nzchar(StartDate)){
StartDate <- format(as.Date(StartDate), format="%m-%d-%Y")
}
if (nzchar(EndDate)){
EndDate <- format(as.Date(EndDate), format="%m-%d-%Y")
retval <- retrieveWQPqwData(siteNumber=siteNumber,
ParameterCd=characteristicName,
StartDate=StartDate,
EndDate=EndDate,
interactive=interactive)
#Check for pcode:
if(all(nchar(characteristicName) == 5)){
suppressWarnings(pCodeLogic <- all(!is.na(as.numeric(characteristicName))))
} else {
pCodeLogic <- FALSE
}
characteristicName <- URLencode(characteristicName)
baseURL <- "http://www.waterqualitydata.us/Result/search?siteid="
url <- paste(baseURL,
siteNumber,
"&characteristicName=",
characteristicName, # to get multi-parameters, use a semicolen
"&startDateLo=",
StartDate,
"&startDateHi=",
EndDate,
"&countrycode=US&mimeType=tsv",sep = "")
h <- basicHeaderGatherer()
doc <- getURI(url, headerfunction = h$update)
numToBeReturned <- as.numeric(h$value()["Total-Result-Count"])
suppressWarnings(retval <- read.delim(url, header = TRUE, quote="\"", dec=".", sep='\t', colClasses=c('character'), fill = TRUE))
qualifier <- ifelse((retval$ResultDetectionConditionText == "Not Detected" |
retval$ResultDetectionConditionText == "Detected Not Quantified" |
retval$ResultMeasureValue < retval$DetectionQuantitationLimitMeasure.MeasureValue),"<","")
correctedData<-ifelse((nchar(qualifier)==0),retval$ResultMeasureValue,retval$DetectionQuantitationLimitMeasure.MeasureValue)
test <- data.frame(retval$CharacteristicName)
# test$dateTime <- as.POSIXct(strptime(paste(retval$ActivityStartDate,retval$ActivityStartTime.Time,sep=" "), "%Y-%m-%d %H:%M:%S"))
test$dateTime <- as.Date(retval$ActivityStartDate, "%Y-%m-%d")
originalLength <- nrow(test)
if (!is.na(numToBeReturned)){
if(originalLength != numToBeReturned) warning(numToBeReturned, " sample results were expected, ", originalLength, " were returned")
test$qualifier <- qualifier
test$value <- as.numeric(correctedData)
test <- test[!is.na(test$dateTime),]
newLength <- nrow(test)
if (originalLength != newLength){
numberRemoved <- originalLength - newLength
warningMessage <- paste(numberRemoved, " rows removed because no date was specified", sep="")
warning(warningMessage)
}
colnames(test)<- c("CharacteristicName","dateTime","qualifier","value")
data <- reshape(test, idvar="dateTime", timevar = "CharacteristicName", direction="wide")
data$dateTime <- format(data$dateTime, "%Y-%m-%d")
data$dateTime <- as.Date(data$dateTime)
return(data)
if(nrow(retval) > 0){
data <- processQWData(retval,pCodeLogic)
} else {
warning("No data retrieved")
data <- NULL
}
return(data)
}
#' Site DAta Import from Water Quality Portal
#' Site Data Import from Water Quality Portal
#'
#' Imports site data from Water Quality Portal web service. This function gets the data from here: \url{http://www.waterqualitydata.us}. This function is more general than getQWData
#' because it allows for other agencies rather than the USGS. Therefore, the 5-digit parameter code cannot be used.
#' Instead, this function uses characteristicName. A complete list can be found here \url{http://www.waterqualitydata.us/Codes/Characteristicname}
#' 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}
#'
#' @param \dots see \url{www.waterqualitydata.us/webservices_documentation.jsp} for a complete list of options
#' @keywords data import WQP web service
......
......@@ -17,6 +17,8 @@
#' data <- getWaterML1Data(obs_url)
#' urlMulti <- constructNWISURL("04085427",c("00060","00010"),startDate,endDate,'dv',statCd=c("00003","00001"))
#' multiData <- getWaterML1Data(urlMulti)
#' goundwaterExampleURL <- "http://waterservices.usgs.gov/nwis/gwlevels/?format=waterml&sites=431049071324301&startDT=2013-10-01&endDT=2014-06-30"
#' groundWater <- getWaterML1Data(goundwaterExampleURL)
getWaterML1Data <- function(obs_url){
# This is more elegent, but requires yet another package dependency RCurl...which I now require for wqp
......@@ -80,12 +82,20 @@ getWaterML1Data <- function(obs_url){
assign(valueName,value)
assign(qualName,qualifier)
df <- data.frame(dateTime,
tzAbbriev,
get(valueName),
get(qualName)
)
names(df) <- c("dateTime","tz_cd",valueName,qualName)
if(length(get(qualName))!=0){
df <- data.frame(dateTime,
tzAbbriev,
get(valueName),
get(qualName)
)
names(df) <- c("dateTime","tz_cd",valueName,qualName)
} else {
df <- data.frame(dateTime,
tzAbbriev,
get(valueName)
)
names(df) <- c("dateTime","tz_cd",valueName)
}
if (1 == i & valuesIndex[1] == j){
mergedDF <- df
......
......@@ -51,14 +51,9 @@ populateDaily <- function(rawData,qConvert,interactive=TRUE){ # rawData is a da
qshift<- 0.001*mean(localDaily$Q, na.rm=TRUE)
if (interactive){
negNums <- length(which(localDaily$Q<0))
zeroNums <- length(which(localDaily$Q == 0))
if (negNums > 0) {
cat("There were", as.character(negNums), "negative flow days \n")
cat("Negative values are not supported in the EGRET package\n")
}
zeroNums <- length(which(localDaily$Q == 0))
if (zeroNums > 0){
cat("There were", as.character(zeroNums), "zero flow days \n")
}
......@@ -70,6 +65,11 @@ populateDaily <- function(rawData,qConvert,interactive=TRUE){ # rawData is a da
qshift<-0.0
}
negNums <- length(which(localDaily$Q<0))
if (negNums > 0) {
cat("There were", as.character(negNums), "negative flow days \n")
cat("Negative values are not supported in the EGRET package\n")
}
localDaily$Q<-localDaily$Q+qshift
......@@ -94,7 +94,20 @@ populateDaily <- function(rawData,qConvert,interactive=TRUE){ # rawData is a da
#these next two lines show the user where the gaps in the data are if there are any
n<-nrow(localDaily)
for(i in 2:n) {if((localDaily$Julian[i]-localDaily$Julian[i-1])>1) cat("\n discharge data jumps from",as.character(localDaily$Date[i-1]),"to",as.character(localDaily$Date[i]))}
for(i in 2:n) {
if((localDaily$Julian[i]-localDaily$Julian[i-1])>1) cat("\n discharge data jumps from",as.character(localDaily$Date[i-1]),"to",as.character(localDaily$Date[i]))
}
numNAs <- sum(is.na(localDaily$Q))
if(numNAs > 0){
cat(numNAs, "discharge measurements are not reported (NA's). \nMany of the EGRET functions will not work with missing discharge measurements.")
if (localDaily$Julian[max(which(is.na(localDaily$Q)),na.rm = TRUE)]-
localDaily$Julian[min(which(is.na(localDaily$Q)),na.rm = TRUE)]+1 == numNAs){
cat("\nNA gap is from",as.character(localDaily$Date[min(which(is.na(localDaily$Q)),na.rm = TRUE)]),"to",
as.character(localDaily$Date[max(which(is.na(localDaily$Q)),na.rm = TRUE)]))
}
}
}
return (localDaily)
......
......@@ -4,16 +4,17 @@
#' conditions to determine if a value is left censored or not. Censored values are given the qualifier
#' "<". The dataframe is also converted from a long to wide format.
#'
#' @param data dataframe from
#' @param data dataframe from Water Quality Portal
#' @param pCode logical if TRUE, assume data came from a pCode search, if FALSE, characteristic name.
#' @keywords data import USGS web service
#' @return data dataframe with first column dateTime, and at least one qualifier and value columns
#' (subsequent qualifier/value columns could follow depending on the number of parameter codes)
#' @export
#' @examples
#' # These examples require an internet connection to run
#' rawSample <- getRawQWData('01594440','01075', '1985-01-01', '1985-03-31')
#' rawSample <- retrieveWQPqwData('USGS-01594440','01075', '1985-01-01', '1985-03-31')
#' rawSampleSelect <- processQWData(rawSample)
processQWData <- function(data){
processQWData <- function(data,pCode=TRUE){
qualifier <- ifelse((data$ResultDetectionConditionText == "Not Detected" |
data$ResultDetectionConditionText == "Detected Not Quantified" |
......@@ -37,8 +38,15 @@ processQWData <- function(data){
warning(warningMessage)
}
colnames(test)<- c("USGSPCode","dateTime","qualifier","value")
data <- suppressWarnings(reshape(test, idvar="dateTime", timevar = "USGSPCode", direction="wide"))
if (pCode){
colnames(test)<- c("USGSPCode","dateTime","qualifier","value")
newTimeVar <- "USGSPCode"
} else {
colnames(test)<- c("CharacteristicName","dateTime","qualifier","value")
newTimeVar <- "CharacteristicName"
}
data <- suppressWarnings(reshape(test, idvar="dateTime", timevar = newTimeVar, direction="wide"))
data$dateTime <- format(data$dateTime, "%Y-%m-%d")
data$dateTime <- as.Date(data$dateTime)
return(data)
......
......@@ -9,10 +9,10 @@
#' @examples
#' # This example requires an internet connection to run
#' siteNumber <- '05114000'
#' rawData <- retrieveNWISData(siteNumber,c("00010","00060","00300"),"2001-01-01","2002-01-01",StatCd=c("00001","00003"))
#' rawData <- retrieveNWISdvData(siteNumber,c("00010","00060","00300"),"2001-01-01","2002-01-01",StatCd=c("00001","00003"))
#' rawData <- renameColumns(rawData)
#' today <- as.character(Sys.Date())
#' rawData2 <- retrieveUnitNWISData(siteNumber,c("00010","00060"),today,today)
#' rawData2 <- retrieveNWISunitData(siteNumber,c("00010","00060"),today,today)
#' rawData2 <- renameColumns(rawData2)
renameColumns <- function(rawData){
......
......@@ -22,11 +22,11 @@
#' startDate <- '2012-01-01'
#' endDate <- '2012-06-30'
#' pCode <- '00060'
#' rawDailyQ <- retrieveNWISData(siteNumber,pCode, startDate, endDate)
#' rawDailyTemperature <- retrieveNWISData(siteNumber,'00010', startDate, endDate, StatCd='00001')
#' rawDailyTemperatureTSV <- retrieveNWISData(siteNumber,'00010', startDate, endDate, StatCd='00001',format='tsv')
#' rawDailyQAndTempMeanMax <- retrieveNWISData(siteNumber,c('00010','00060'), startDate, endDate, StatCd=c('00001','00003'))
retrieveNWISData <- function (siteNumber,ParameterCd,StartDate,EndDate,StatCd="00003",format="tsv",interactive=TRUE){
#' rawDailyQ <- retrieveNWISdvData(siteNumber,pCode, startDate, endDate)
#' rawDailyTemperature <- retrieveNWISdvData(siteNumber,'00010', startDate, endDate, StatCd='00001')
#' rawDailyTemperatureTSV <- retrieveNWISdvData(siteNumber,'00010', startDate, endDate, StatCd='00001',format='tsv')
#' rawDailyQAndTempMeanMax <- retrieveNWISdvData(siteNumber,c('00010','00060'), startDate, endDate, StatCd=c('00001','00003'))
retrieveNWISdvData <- function (siteNumber,ParameterCd,StartDate,EndDate,StatCd="00003",format="tsv",interactive=TRUE){
url <- constructNWISURL(siteNumber,ParameterCd,StartDate,EndDate,"dv",statCd=StatCd,format=format,interactive=interactive)
......
......@@ -21,9 +21,9 @@
#' StartDate <- as.character(Sys.Date())
#' EndDate <- as.character(Sys.Date())
#' # These examples require an internet connection to run
#' rawData <- retrieveUnitNWISData(siteNumber,ParameterCd,StartDate,EndDate)
#' rawData2 <- retrieveUnitNWISData(siteNumber,ParameterCd,StartDate,EndDate,"tsv")
retrieveUnitNWISData <- function (siteNumber,ParameterCd,StartDate,EndDate,format="xml",interactive=TRUE){
#' rawData <- retrieveNWISunitData(siteNumber,ParameterCd,StartDate,EndDate)
#' rawData2 <- retrieveNWISunitData(siteNumber,ParameterCd,StartDate,EndDate,"tsv")
retrieveNWISunitData <- function (siteNumber,ParameterCd,StartDate,EndDate,format="xml",interactive=TRUE){
url <- constructNWISURL(siteNumber,ParameterCd,StartDate,EndDate,"uv",format=format,interactive=interactive)
if (format == "xml") {
......
......@@ -45,7 +45,7 @@ url_daily <- constructNWISURL(siteNumber,pCode,startDate,endDate,'dv',statCd=c("
url_unit <- constructNWISURL(siteNumber,pCode,"2012-06-28","2012-06-30",'iv')
url_qw_single <- constructNWISURL(siteNumber,"01075",startDate,endDate,'qw')
url_qw <- constructNWISURL(siteNumber,c('01075','00029','00453'),startDate,endDate,'qw')
url_wqp <- constructNWISURL(siteNumber,c('01075','00029','00453'),startDate,endDate,'wqp')
url_wqp <- constructNWISURL(paste("USGS",siteNumber,sep="-"),c('01075','00029','00453'),startDate,endDate,'wqp')
url_daily_tsv <- constructNWISURL(siteNumber,pCode,startDate,endDate,'dv',statCd=c("00003","00001"),format="tsv")
}
\keyword{USGS}
......
......@@ -40,7 +40,7 @@ DailyCFS <- getDVData('01594440','00060', '1985-01-01', '1985-03-31',convert=FAL
DailySuspSediment <- getDVData('01594440','80154', '1985-01-01', '1985-03-31')
}
\seealso{
\code{\link{retrieveNWISData}}, \code{\link{populateDaily}}
\code{\link{retrieveNWISdvData}}, \code{\link{populateDaily}}
}
\keyword{USGS}
\keyword{WRTDS}
......
% Generated by roxygen2 (4.0.1): do not edit by hand
\name{getQWData}
\alias{getQWData}
\title{Data Import for USGS NWIS Water Quality Data}
\usage{
getQWData(siteNumber, ParameterCd, StartDate, EndDate, interactive = TRUE)
}
\arguments{
\item{siteNumber}{string USGS site number. This is usually an 8 digit number}
\item{ParameterCd}{string USGS parameter code. This is usually an 5 digit number. Multiple parameter codes can be inputted with a ';' separator. Leaving this blank will return all of the measured values during the specified time period.}
\item{StartDate}{string starting date for data retrieval in the form YYYY-MM-DD.}
\item{EndDate}{string ending date for data retrieval in the form YYYY-MM-DD.}
\item{interactive}{logical Option for interactive mode. If true, there is user interaction for error handling and data checks.}
}
\value{
retval dataframe with first column dateTime, and at least one qualifier and value columns
(subsequent qualifier/value columns could follow depending on requested parameter codes)
}
\description{
Imports and processes data from NWIS web service. This function gets the data from here: \url{http://www.waterqualitydata.us}
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}
}
\examples{
# These examples require an internet connection to run
rawProcessedSample <- getQWData('01594440','01075', '1985-01-01', '1985-03-31')
rawProcessedSampleAll <- getQWData('05114000','', '1985-01-01', '1985-03-31')
rawProcessedSampleSelect <- getQWData('05114000','00915;00931', '1985-01-01', '1985-04-30')
}
\keyword{USGS}
\keyword{data}
\keyword{import}
\keyword{service}
\keyword{web}
......@@ -21,11 +21,9 @@ getSTORETSampleData(siteNumber, characteristicName, StartDate, EndDate,
Sample dataframe
}
\description{
Imports data from NWIS web service. This function gets the data from here: \url{http://qwwebservices.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}
For raw data, use getQWData. This function will retrieve the raw data, and compress it (summing constituents). See
chapter 7 of the EGRET user guide for more details.
Imports data from the Water Quality Portal. This function gets the data from: \url{http://www.waterqualitydata.us}
For raw data, use getWQPData. This function will retrieve the raw data, and compress it (summing constituents). See
chapter 7 of the EGRET user guide for more details, then converts it to the Sample dataframe structure.
}
\examples{
# These examples require an internet connection to run
......
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