Learn R Programming

dataRetrieval (version 2.0.0)

importWaterML2: Function to return data from the WaterML2 data

Description

This function accepts a url parameter for a WaterML2 getObservation

Usage

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

Arguments

obs_url

string containing the url for the retrieval

asDateTime

logical, if TRUE returns date and time as POSIXct, if FALSE, Date

tz

string 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 containing columns agency, site, dateTime, values, and remark codes for all requested combinations

Examples

Run this code
# NOT RUN {
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)
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