View source: R/spatial_matrices.R
circular_window | R Documentation |
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.
circular_window(radius, res)
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. |
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.
A binary weight matrix
# wide of 100 metres for pixels of 2 metres
window <- circular_window(100, 2)
# row standardisation
window_row_std <- window / sum(window)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.