Learn R Programming

dataRetrieval (version 2.5.1)

importWaterML2: Function to return data from the WaterML2 data

Description

This function accepts a url parameter for a WaterML2 getObservation. This function is still under development, but the general functionality is correct.

Usage

importWaterML2(obs_url, asDateTime = FALSE, tz = "")

Arguments

obs_url
character containing the url for the retrieval or a file path to the data file.
asDateTime
logical, if TRUE returns date and time as POSIXct, if FALSE, Date
tz
character to set timezone attribute of datetime. Default is an empty quote, which converts the datetimes to UTC (properly accounting for daylight savings times based on the data's provided tz_cd column). Possible values to provide are "America/New_York","America/Chicago", "America/Denver","America/Los_Angeles", "America/Anchorage","America/Honolulu","America/Jamaica","America/Managua","America/Phoenix", and "America/Metlakatla"

Value

mergedDF a data frame time, value, description, qualifier, and identifier

Examples

Run this code
baseURL <- "http://waterservices.usgs.gov/nwis/dv/?format=waterml,2.0"
URL <- paste(baseURL, "sites=01646500",
     "startDT=2014-09-01",
     "endDT=2014-09-08",
     "statCd=00003",
     "parameterCd=00060",sep="&")
URL2 <- paste("http://cida.usgs.gov/noreast-sos/simple?request=GetObservation",
     "featureID=MD-BC-BC-05",
     "offering=RAW",
     "observedProperty=WATER",sep="&")
## Not run: 
# dataReturned1 <- importWaterML2(URL)
# dataReturn2 <- importWaterML2(URL2, TRUE)
# URLmulti <-  paste(baseURL,
#   "sites=04024430,04024000",
#   "startDT=2014-09-01",
#   "endDT=2014-09-08",
#   "statCd=00003",
#   "parameterCd=00060",sep="&")
# dataReturnMulti <- importWaterML2(URLmulti)
# ## End(Not run)
filePath <- system.file("extdata", package="dataRetrieval")
fileName <- "WaterML2Example.xml"
fullPath <- file.path(filePath, fileName)
UserData <- importWaterML2(fullPath)

Run the code above in your browser using DataLab