Unlimited learning, half price | 50% off

Last chance! 50% off unlimited learning

Sale ends in


bfastSpatial (version 0.6.2)

flattenBrick: Convert a RasterBrick or RasterStack to a RasterLayer based on the first encountered value

Description

Flatten a brick by iteratively masking layer values by non-NA values in preceding layers. An optional threshold can be supplied, where preceding values exceeding the threshold are ignored in the masking procedure (and are therefore themselves removed).

Usage

flattenBrick(x, thresh = NULL, ...)

Arguments

x

RasterBrick or RasterStack.

thresh

Numeric. Optional: threshold to apply to preceding values in deciding whether to mask subsequent values.

...

Additional arguments to be bassed to mc.calc.

Value

RasterLayer with values representing 'earliest' encountered values not exceeding thresh.

Details

thresh only works on a 'greater-than' basis. To achieve the reverse, first let x <- -1*x then convert the result back by y <- -1*y.

Examples

Run this code
# NOT RUN {
# load Tura dataset
data(tura)

## apply a very crude gap-fill using 2 Landsat
# the 1st layer has alot of gaps from the cloud mask
# suppose this is our target image and we want to use the 2nd layer to fill
# just take these two layers
gapfill <- tura[[c(1:2)]]
names(gapfill) <- c("target", "fill")
plot(gapfill)

# flatten the Brick to fill the gaps (NA's in the 1st layer)
filled <- flattenBrick(gapfill)
plot(filled)
# }

Run the code above in your browser using DataLab