Patch creation algorithm can occasionally leave single cells scattered within patches. This function reduces the "salt-pepper" effect, identifying or correcting those cells.
input raster landscape.
logical, if TRUE returns the raster without single tones cells, if FALSE a vector of numbers identifying the index of single tones cells.
A raster without single tones cells. If
rm=FALSE, it returns a vector of numbers identifying the index of single tones cells.
The value assigned to single tone cells is picked from one of the four neighbouring cells, selected at random.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
library(raster) m = matrix(0, 33, 33) r = raster(m, xmn=0, xmx=10, ymn=0, ymx=10) patchSize = 500 ## Make a patch and introduce a single tone cell r = makePatch(r, patchSize, spt=578, rast=TRUE) r = 0 plot(r) ## Now remove it plot( rmSingle(r) ) ## Single tones can be identified but not removed: rmSingle(r, rm = FALSE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.