Ngwmn cleanups
Merge request reports
Activity
Filter activity
I took out reference to "_wml2" in the names. I think that's not super important to the user. I also tested the timeseries parser on the USGS services. It gets the values and dates, so I think we can just make that our general "base" WaterML2 parser. We should in the future try to get the "default" behavior back in there, and see if we can make it smart enough to handle some comments that are bundled with the TVPs.
7 7 #' @param asDateTime logical, if \code{TRUE} returns date and time as POSIXct, if \code{FALSE}, character 8 8 #' @param tz character to set timezone attribute of datetime. Default is an empty quote, which converts the 9 9 #' datetimes to UTC (properly accounting for daylight savings times based on the data's provided time zone offset). 10 #' Possible values to provide are "America/New_York","America/Chicago", "America/Denver","America/Los_Angeles", 10 #' Possible values are "America/New_York","America/Chicago", "America/Denver","America/Los_Angeles", 123 131 #' @importFrom lubridate parse_date_time 124 132 #' @export 125 parseWaterML2Timeseries <- function(input, asDateTime, tz) { 126 gmlID <- xml_attr(input,"id") #TODO: make this an attribute 127 TVP <- xml_find_all(input, ".//wml2:MeasurementTVP")#time-value pairs 133 #' @examples 134 #' baseURL <- "https://waterservices.usgs.gov/nwis/dv/?format=waterml,2.0" 135 #' URL <- paste(baseURL, "sites=01646500", 136 #' "startDT=2014-09-01", 137 #' "endDT=2014-09-08", 138 #' "statCd=00003", 139 #' "parameterCd=00060",sep="&") 140 #' \dontrun{ 141 #' timesereies <- importWaterML2(URL, asDateTime=TRUE, tz="UTC") 142 #' } 143 importWaterML2 <- function(input, asDateTime=FALSE, tz="UTC") { 7 7 #' @param asDateTime logical, if \code{TRUE} returns date and time as POSIXct, if \code{FALSE}, character 8 8 #' @param tz character to set timezone attribute of datetime. Default is an empty quote, which converts the 9 9 #' datetimes to UTC (properly accounting for daylight savings times based on the data's provided time zone offset). 10 #' Possible values to provide are "America/New_York","America/Chicago", "America/Denver","America/Los_Angeles", 10 #' Possible values are "America/New_York","America/Chicago", "America/Denver","America/Los_Angeles", 123 131 #' @importFrom lubridate parse_date_time 124 132 #' @export 125 parseWaterML2Timeseries <- function(input, asDateTime, tz) { 126 gmlID <- xml_attr(input,"id") #TODO: make this an attribute 127 TVP <- xml_find_all(input, ".//wml2:MeasurementTVP")#time-value pairs 133 #' @examples 134 #' baseURL <- "https://waterservices.usgs.gov/nwis/dv/?format=waterml,2.0" 135 #' URL <- paste(baseURL, "sites=01646500", 136 #' "startDT=2014-09-01", 137 #' "endDT=2014-09-08", 138 #' "statCd=00003", 139 #' "parameterCd=00060",sep="&") 140 #' \dontrun{ 141 #' timesereies <- importWaterML2(URL, asDateTime=TRUE, tz="UTC") 142 #' } 143 importWaterML2 <- function(input, asDateTime=FALSE, tz="UTC") {
Please register or sign in to reply