f <- system.file("external/test.grd", package="raster")
rr <- rasterList(f)
rs <- as.RasterList(f)
# The package-provided datasets shall be only used as example datasets.
precf <- system.file("map/precipitation.grd", package="rasterList")##
## A resampled preciptation raster map based on CHIRS dataset:
## Funk, Chris, Pete Peterson, Martin Landsfeld, Diego Pedreros, James Verdin,
## Shraddhanand Shukla, Gregory Husak, James Rowland, Laura Harrison,
## Andrew Hoell and Joel Michaelsen.
## "The climate hazards infrared precipitation with stations - a new environmental
## record for monitoring extremes". Scientific Data 2, 150066. doi:10.1038/sdata.2015.66 2015.
## http://chg.geog.ucsb.edu/data/chirps/
##
if (FALSE) {
if (requireNamespace("lmom",quietly = TRUE) & requireNamespace("lubridate",quietly = TRUE)) {
## Sample L-moments
library(lmom)
library(lubridate)
prec <- stack(precf)
samlmom <- stack(rasterList(prec,FUN=samlmu))
## Fitting a Random Probability Distribution: it is a 'rasterList' Object
fitdist <- rasterList(samlmom,FUN=pelgam)
}
}
if (requireNamespace("lmom",quietly = TRUE) & requireNamespace("lubridate",quietly = TRUE)) {
library(lmom)
library(lubridate)
precf <- system.file("map/Mekrou_precipitation.grd", package="rasterList")
prec <- stack(precf)
# Set time
time <- as.Date(names(prec),format="X%Y.%m.%d")
year <- sprintf("X%04d",lubridate::year(time)) ##as.character(time,format="X%Y")
## Compute Annual Precipitation (sum aggregration)
yearlyprec <- stackApply(x=prec,fun=sum,indices=year)
## L-moments
samlmom <- stack(rasterList(yearlyprec,FUN=samlmu))
fitdist <- rasterList(samlmom,FUN=pelgam)
}
Run the code above in your browser using DataLab