Commit ffb4ae2b by Jan Wijffels

add phenomena labels

parent c9deeaf9
......@@ -17,6 +17,7 @@
#' \item{lon: longitude of the station}
#' \item{lat: latitude of the station}
#' \item{phenomena: a list of phenomena identifiers for each station}
#' \item{phenomena_label: a list of phenomena labels for each station}
#' \item{timeseries: a list of timeseries identifiers for each station}
#' }
#' @examples
......@@ -46,6 +47,7 @@ read_stations <- function(x = sensorweb4R::as.Endpoint("http://geo.irceline.be/s
})
stat <- rbindlist(lapply(sta, FUN=function(x) x[c("id", "label", "lon", "lat")]))
stat$phenomena <- lapply(sta, FUN=function(x) x$phenomena)
stat$phenomena_label <- lapply(sta, FUN=function(x) txt_recode(x$phenomena, from = phe$id, to = phe$label))
stat$timeseries <- lapply(sta, FUN=function(x) x$timeseries)
result <- list()
result$phenomena <- phe
......
txt_recode <- function (x, from = c(), to = c()) {
stopifnot(length(from) == length(to))
nongiven <- unique(x[!is.na(x)])
nongiven <- setdiff(nongiven, from)
if (length(nongiven) > 0) {
from <- append(x = from, values = nongiven)
to <- append(x = to, values = nongiven)
}
to[match(x, from)]
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment