rSegregate: Segregate values of a raster into layers

Description Usage Arguments Value See Also Examples

View source: R/modify.operators.R

Description

Distinct values in a raster will be assigned to layers in a raster stack.

Usage

1
rSegregate(obj, by = NULL, flatten = FALSE, background = NULL)

Arguments

obj

[RasterLayer(1)]
The object to modify.

by

[RasterLayer(1)]
optional object by which obj should be segregated. If left empty, the distinct values of obj will be taken.

flatten

[logical(1)]
should all values be set to value 1 (TRUE) or should the original obj values be retained (FALSE, default)?

background

[integerish(1)]
the value any cell with value NA should have.

Value

a RasterStack of the same dimensions as obj, in which the elements specified in by or the distinct values of obj have each been assigned to a seperate layer.

See Also

Other operators to modify a raster: rBlend, rReduce, rRescale

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
input <- rtRasters$continuous
patches <- rPatches(rBinarise(input, thresh = 30), background = 0)
myPatches <- rSegregate(patches)
visualise(myPatches[[c(2, 3, 12, 16)]])

# when flattening, all values are set to 1
myPatches2 <- rSegregate(patches, flatten = TRUE)
visualise(myPatches2[[c(2, 3, 12, 16)]])

# cut out by 'patches'
patchValues <- rSegregate(input, by = patches)
visualise(patchValues[[c(2, 3, 12, 16)]])

EhrmannS/rasterTools documentation built on Sept. 4, 2019, 10:34 a.m.