[R-sig-Geo] customized focal mean

hariom hariom.cs1 at gmail.com
Wed Apr 1 07:52:50 CEST 2015


Hello,

Thanks for your reply...

I am new in R programming and I have tried this code but no success.

library(raster)
seq1 <- seq(1:16)
x <- matrix(seq1, 4)
rc2 <- raster(x)

u1 <- matrix(1,3,3)

# apply the function to a 3x3 moving window
aggr <- as.matrix(focal(rc2, w=u1, fun=mean,na.rm=TRUE))

c <- raster(aggr)
spplot(c)

It is calculating by default mean but I need as I have already described.
Where I need to customize the code so that I could get my result. Kindly
help me to customize this type of mean I would appreciate for your time and
concern.





--
View this message in context: http://r-sig-geo.2731867.n2.nabble.com/customized-focal-mean-tp7587890p7587995.html
Sent from the R-sig-geo mailing list archive at Nabble.com.



More information about the R-sig-Geo mailing list