Learn R Programming

inlmisc (version 0.3.2)

RmSmallCellChunks: Remove Small Cell Chunks

Description

This function identifies cell chunks in a single raster grid layer, where a cell chunk is defined as a group of connected cells with non-missing values. The cell chunk with the largest surface area is preserved and all others removed.

Usage

RmSmallCellChunks(r)

Arguments

r

'RasterLayer'. A raster grid layer with cell values.

Value

Returns a 'RasterLayer' object, r with cell values in the smaller cell chunks set to NA.

See Also

clump

Examples

Run this code
# NOT RUN {
set.seed(10)
r <- raster::raster(ncols = 10, nrows = 10)
r[] <- round(runif(raster::ncell(r)) * 0.7)
r <- raster::clump(r)
raster::plot(r)

r.new <- RmSmallCellChunks(r)
raster::plot(r.new, zlim = range(r[], na.rm = TRUE))

# }

Run the code above in your browser using DataLab