c: "Stack" GRasters

c,GRaster-methodR Documentation

"Stack" GRasters

Description

GRasters can be "stacked" using this function, effectively creating a multi-layered raster. This is different from creating a 3-dimensional raster, though such an effect can be emulated using stacking. GVectors can be combined into a single vector. Stacks can only be created when:

  • All objects are the same class (either all GRasters or all GVectors).

  • All objects have the same coordinate reference system (see crs()).

  • Horizontal extents are the same (see ext()).

  • Horizontal dimensions are the same (see res()).

  • The topology (2- or 3-dimensional) must be the same. If 3D, then all rasters must have the same number of depths and vertical extents (see topology()).

Data tables associated with GVectors will be combined if each vector has a table and if each table has the same columns and data types. Otherwise, the data table will be combined using merge().

Usage

## S4 method for signature 'GRaster'
c(x, ...)

Arguments

x

A GRaster or a GVector.

...

One or more GRasters, one or more GVectors, a list of GRasters, or a list of GVectors. You can use a mix of lists and individual rasters or vectors.

Value

A GRaster.

See Also

add<-, terra::c(), add<-

Examples

if (grassStarted()) {

# Setup
madForest2000 <- fastData("madForest2000")
madForest2014 <- fastData("madForest2014")

# Convert SpatRasters to GRasters:
forest2000 <- fast(madForest2000)
forest2014 <- fast(madForest2014)

# Combine:
forest <- c(forest2000, forest2014)
forest

nlyr(forest)

}

adamlilith/fasterRaster documentation built on Dec. 21, 2024, 2:04 a.m.