library(terra)
m = matrix(0, 33, 33)
r = rast(m)
ext(r) = c(0, 10, 0, 10)
patchSize = 500
## Make a patch and introduce a single tone cell
r = makePatch(r, patchSize, spt=578, rast=TRUE)
r[578] = 0
plot(r)
## Now remove it
plot( rmSingle(r) )
## Single tones can be identified but not removed:
rmSingle(r, rm = FALSE)
Run the code above in your browser using DataLab