combine

0th

Percentile

raster combine

Combines rasters into all unique combinations of inputs

Usage
combine(x, rnames = NULL, sp = FALSE)
Arguments
x

raster stack/brick or SpatialPixelsDataFrame object

rnames

Column names to combine in raster stack or sp object

sp

(FALSE/TRUE) output SpatialPixelsDataFrame

Details

Please note that this is not a memory safe function that utilizes rasters out of memory in the manner that the raster package does.

If sp = TRUE the object will be a list with "combine", containing the SpatialPixelsDataFrame with the value attribute containing the unique combinations, and "summary" with the summary table of collapsed combinations and associated attributes.

If sp = FALSE the a single ratified rasterLayer class object is returned with the summary table as the raster attribute table, this is most similar to the ESRI format resulting from their combine function.

Value

A ratified rasterLayer or a list containing a SpatialPixelsDataFrame and a data.frame of unique combinations.

Aliases
  • combine
Examples
# NOT RUN {
library(raster)

r1 <- raster(nrows=100, ncol=100)
  r1[] <- round(runif(ncell(r1), 1,4),0)
r2 <- raster(nrows=100, ncol=100)
  r2[] <- round(runif(ncell(r2), 2,6),0)
r3 <- raster(nrows=100, ncol=100)
  r3[] <- round(runif(ncell(r3), 2,6),0)
r <- stack(r1,r2,r3)  
  names(r) <- c("LC1","LC2","LC3")

# Combine rasters in stack
( cr <- combine(r) )
  levels(cr)
  
# Combine rasters in stack, using specific rasters
( cr <- combine(r, rnames=c("LC1","LC3")) )

# Combine rasters in stack, output SpatialPixelsDataFrame
cr.sp <- combine(r, sp = TRUE)
  head(cr.sp$summary)
  class(cr.sp$combine)

# Input SpatialPixelsDataFrame 
r.sp <- as(r, "SpatialPixelsDataFrame")
cr.sp <- combine(r.sp, sp = TRUE)

# }
Documentation reproduced from package spatialEco, version 1.3-2, License: GPL-3

Community examples

Looks like there are no examples yet.