clump

0th

Percentile

Detect clumps

Detect clumps (patches) of connected cells. Each clump gets a unique ID. NA and zero are used as background values (i.e. these values are used to separate clumps). You can use queen's or rook's case, using the directions argument. For larger files that are processed in chunks, the highest clump number is not necessarily equal to the number of clumps (unless you use argument gaps=FALSE).

Keywords
spatial
Usage
# S4 method for RasterLayer
clump(x, filename="", directions=8, gaps=TRUE, ...)
Arguments
x

RasterLayer

filename

Character. Filename for the output RasterLayer (optional)

directions

Integer. Which cells are considered adjacent? Should be 8 (Queen's case) or 4 (Rook's case)

gaps

Logical. If TRUE (the default), there may be 'gaps' in the chunk numbers (e.g. you may have clumps with IDs 1, 2, 3 and 5, but not 4). If it is FALSE, these numbers will be recoded from 1 to n (4 in this example)

...

Additional arguments as for writeRaster

RasterLayer

Note

This function requires that the igraph package is available.

Aliases
• clump
• clump,RasterLayer-method
Examples
# NOT RUN {
r <- raster(ncols=12, nrows=12)
set.seed(0)
r[] <- round(runif(ncell(r))*0.7 )
rc <- clump(r)
freq(rc)
plot(rc)
# }

Documentation reproduced from package raster, version 2.7-15, License: GPL (>= 3)

Community examples

Looks like there are no examples yet.