Dear Researchers,

Sorry if I use your time with this email, but I wish to ask a suggestion to
build-up a special filter in a forest/no forest classification. In the end
of my methodology I have a raster image with Forest (pixel with 0 value) and
No forest area (pixel with 1 value). But when plot the raster I can see some
noise of my methodology (single isolate pixels with "0" value and single
isolate pixels with "1". PS: the resolution of my map is 1x1 m and It's not
possible a forest gap with area <= of 1 m square and not possible a forest
with the same area in a Gap). I wish to create a filter to eliminate these
pixel:

example
"1" value pixel around 8 "0" value pixels = Became "0"
"0" value pixel around 8 "1" value pixels = Became "1"

you could see with this example:

library(raster)

va <- c(0,0,0,0,0,0,0,0,0,0,0,1,0,0,
0,1,0,0,0,0,
        0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
        0,0,1,1,1,1,1,1,1,1,1,0,1,0,1,1,1,1,1,0,
        0,0,1,1,1,1,1,1,1,1,0,0,0,1,1,1,1,1,1,1,
        0,1,0,0,0,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0)

r <- raster(ncols=10, nrows=10)
r <- setValues(r, va)
plot(r,  maxpixels = 1000, col=c("blue","red"), main="before filter")

va2 <- c(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,
        0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
        0,0,1,1,1,1,1,1,1,1,1,0,1,1,1,1,1,1,1,0,
        0,0,1,1,1,1,1,1,1,1,0,0,0,1,1,1,1,1,1,1,
        0,1,0,0,0,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0)

rfinal <- raster(ncols=10, nrows=10)
rfinal  <- setValues(r, va2)
plot(rfinal,  maxpixels = 1000, col=c("blue","red"), main="after filter")


Thanks for attention
Gianni

	[[alternative HTML version deleted]]

