I have a large raster data set (several actually). I'm looking for a moving window process for R (like 'focal' in the raster package). However, the function to apply to the window needs to be caclulated relative to the center cell of said window.
For a simple example, I would like a moving window function that tells me how many of the cells in the window are within some value 'd' of the center cell of the window. I suspect I could do this easily by simply querying the value of the center cell and writing a function around it to use in focal(). However, I'm not sure how to query that center cell of the window.
If that's possible, then I will eventually need to run this function on one raster based on the value of the center cell in another perfectly overlaid raster (which could be in a stack or something).
I'm comfortable with raster work, but not that familiar with the focal() command from the {raster} package in R. Hoping someone can provide some info.