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
).## S3 method for class 'RasterLayer':
clump(x, filename="", directions=8, gaps=TRUE, ...)
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)writeRaster
r <- raster(ncols=12, nrows=12)
set.seed(0)
r[] <- round(runif(ncell(r))*0.7 )
rc <- clump(r)
freq(rc)
plot(rc)
Run the code above in your browser using DataLab