rasterList: Creates a 'RasterList-class' object

rasterListR Documentation

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 signature 'RasterLayer'
rasterList(object = NULL, list = NULL, object.name = NA, ...)

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

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

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

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.

Value

a RasterList-class object.

Examples


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/
##
## Not run: 
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)
}

## End(Not run)

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)

}


rasterList documentation built on Aug. 17, 2023, 5:07 p.m.