I want to calculate the sum of a moving window circle in R for each center cell. Is there a way to do this in R with focal or focalWeights on my raster (preferrably with map units)? Focal does not take circle or map units and focalWeight gives only weighted sums.
I am looking for an alternative to FocalStatisticas (in Esri) in R.
I found a thread at http://r-sig-geo.2731867.n2.nabble.com/Raster-package-Focal-sum-in-circles-td7587683.html which is tackeling quite a similar idea, which made me come up with a code similar to this.
fwModel <- focalWeight(modell_soil, 25, type='circle') fwModel[fwModel>0] <- 1 p_focal<-focal(modell_soil, w=fwModel ,fun=sum , na.rm=TRUE)
This code allowes me to use the focal command with a circluar window and map units. The only problem I have until now, is that it does not allow me yet to only calculate the sum for the center cell instead of the whole circular window. I tried quite some things but did not get closer to the solution... Is there a way to tackle the center cell that could fit in my method above?
NAs are actually not a problem for me, as I do not have any in my raster. It's just part of the thread (in the link, so I included it in my trie-outs).
When I had to use rectangular windows I already learned to tackle the center cell, but I am not sure how to use it with a circular window.