meStack: meStack

Description Usage Arguments Details Value Examples

View source: R/meStack.R

Description

Stacking of raster layers with different extents

Usage

1
meStack(x, y, z, agg.fun = mean, derive.stats = FALSE)

Arguments

x

A list of RasterLayer objects or a character vector with the paths to raster objects.

y

A spatial object from which an extent can be derived.

z

Object of class Date with the acquisition date for each element in x.

agg.fun

Function used to aggregate images collected in the same date. Default is the mean.

derive.stats

Logical argument. Default is FALSE.

Details

The function stacks the raster objects specified in x. For each element in x, the function crops it by the extent of y and, if their extents differ, fits the extent of x to the one of y. All new pixels are set to NA. If z is provided, the function will then aggregate all bands acquired in the same date using the function provide with agg.fun. If derive.stats is set to TRUE, the function will return basic statistics for each band (i.e. min, max, mean and sd) together with a plot of the mean values. The final output of the function is a list containing:

Value

A list containing a RasterStack and related statistics.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
{

require(raster)

r1 <- raster(xmn=1, xmx=90, ymn=1, ymx=90, res=1, vals=1) # image 1
r2 <- raster(xmn=50, xmx=150, ymn=50, ymx=150, res=1, vals=1) # image 2
r0 <- raster(xmn=20, xmx=90, ymn=50, ymx=90, res=1, vals=1) # target extent

crs(r0) <- crs(r2) <- crs(r1)

mes <- meStack(list(r1, r2), r0)
plot(mes$stack)

}

CAWaR documentation built on July 8, 2020, 7:06 p.m.