### function to read GLC-Share as stack
# the stack consists of different layers for the different land use classes
# they are for one year only
# should the file source being defined by a variable "file" or by a config file?
#' Reads in GLC-SHARE data
#'
#' Function reads in GLCN: Global Land Cover-SHARE data
#'
#'
#' @usage readGlcShare()
#' @return A raster object with the data
#' @author Ulrich Kreidenweis
#' @examples
#'
#' \dontrun{readGlcShare()}
#'
#' @export readGlcShare
#' @importFrom raster stack raster addLayer
#' @importFrom utils unzip
readGlcShare <- function() {
# GLCclassification <- read.csv("GLC-SHARE/classification.csv")
GLC <- stack()
# maybe better use brick() instead
for (i in 1:length(GLCclassification$class)) {
file <- unzip(paste0("GLC-SHARE/GlcShare_v10_", formatC(GLCclassification$class[i], width = 2, format = "d", flag = "0"), ".zip"))
rasterfile <- raster(file[1])
names(rasterfile) <- GLCclassification$shortname[i]
GLC <- addLayer(GLC, rasterfile)
}
return(GLC)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.