Create a matrix that can be used as a window when working with
rasters. It uses a radius to set to 0 the weights of pixels that are farther
than this distance. This is helpful to create circular focals.
Usage
circular_window(radius, res)
Value
A binary weight matrix
Arguments
radius
The size in metres of the radius of the circular focal
res
The width in metres of a pixel. It is assumed that pixels are squares.
Details
The original function comes from here: https://scrogster.wordpress.com/2012/10/05/applying-a-circular-moving-window-filter-to-raster-data-in-r/
but we reworked it to make it faster and to ensure that the result is a matrix with odd dimensions.