Learn R Programming

rasterList (version 0.5.20)

rasterList: Creates a RasterList-class object

Description

The method rasterList is the constructor of a RasterList-class from a generic object.

Usage

rasterList(object = NULL, list = NULL, object.name = NA, ...)

as.RasterList(object, ...)

rasterList(object = NULL, list = NULL, object.name = NA, ...)

# S4 method for RasterLayer rasterList(object = NULL, list = NULL, object.name = NA, ...)

# S4 method for RasterStack rasterList(object = NULL, list = NULL, object.name = NA, ...)

# S4 method for RasterBrick rasterList(object = NULL, list = NULL, object.name = NA, ...)

# S4 method for RasterList rasterList(object, list = NULL, object.name = NA, FUN = NULL, ...)

Value

a RasterList-class object.

Arguments

object

the object to coerce

list

a list object to assign to the raster map.

object.name

character string containing the name to assign to object.

...

further arguments for raster(generic) or FUN (RasterList-class)

FUN

function that can be used to apply to each element of the list in a RasterList-class

Details

The argument FUN is useful to create or transform RasterList-class from other Raster* classes.

Examples

Run this code

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