diff --git a/NAMESPACE b/NAMESPACE index f1d2b6d2a24a646aa5a176b6dfe5be2b2e29933b..0a98d2bf9c9d85c35e406542ce00371798c987c7 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -15,6 +15,7 @@ export(getDataAvailability) export(getDataFromFile) export(getGeneralWQPData) export(getMetaData) +export(getNWISData) export(getNWISSites) export(getParameterInfo) export(getQWDataFromFile) diff --git a/R/getNWISData.r b/R/getNWISData.r new file mode 100644 index 0000000000000000000000000000000000000000..64f286f60ec579e00f84b93710a9c74e133e0886 --- /dev/null +++ b/R/getNWISData.r @@ -0,0 +1,31 @@ +#' 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/rest/Site-Service.html#Service} +#' +#' @param service string +#' @param \dots see \url{http://waterservices.usgs.gov/rest/Site-Service.html#Service} for a complete list of options +#' @keywords data import NWIS web service +#' @return retval dataframe +#' @export +#' @examples +#' dataTemp <- getNWISData(stateCd="OH",parameterCd="00010") +getNWISData <- function(service="dv", ...){ + + matchReturn <- match.call() + + values <- sapply(matchReturn[-1], function(x) URLencode(as.character(paste(eval(x),collapse="",sep="")))) + + urlCall <- paste(paste(names(values),values,sep="="),collapse="&") + + + baseURL <- paste0("http://waterservices.usgs.gov/nwis/",service,"/?format=rdb&") + urlCall <- paste0(baseURL,urlCall) + if(service=="qw"){ + urlCall <- paste0(urlCall,"&siteOutput=expanded") + } + + retval <- getRDB1Data(urlCall) + + return(retval) +} diff --git a/man/getNWISData.Rd b/man/getNWISData.Rd new file mode 100644 index 0000000000000000000000000000000000000000..6f95b8445c65370730d0fa136420764ebe1033a0 --- /dev/null +++ b/man/getNWISData.Rd @@ -0,0 +1,28 @@ +% Generated by roxygen2 (4.0.2): do not edit by hand +\name{getNWISData} +\alias{getNWISData} +\title{General Data Import from NWIS} +\usage{ +getNWISData(service = "dv", ...) +} +\arguments{ +\item{services}{string} + +\item{\dots}{see \url{http://waterservices.usgs.gov/rest/Site-Service.html#Service} for a complete list of options} +} +\value{ +retval dataframe +} +\description{ +Returns data from the NWIS web service. +Arguments to the function should be based on \url{http://waterservices.usgs.gov/rest/Site-Service.html#Service} +} +\examples{ +dataTemp <- getNWISData(stateCd="OH",parameterCd="00010") +} +\keyword{NWIS} +\keyword{data} +\keyword{import} +\keyword{service} +\keyword{web} +