Calculates an optimal “moving window” matrix size for use when extracting spatially buffered explanatory variables, by using the radius of interest and spatial resolution of environmental data.
radial.distance: a numeric value, the radius of interest in metres.
spatial.res.degrees: a numeric value, the spatial resolution in degrees of explanatory variable data.
spatial.res.metres: a numeric value, the spatial resolution in metres of explanatory variable data.
spatial.ext: the spatial extent of the study. Object from which extent can be extracted of class SpatExtent, SpatRaster, sf polygon or numeric vector listing xmin, xmax, ymin and ymax in order.
Returns
Returns "moving window" matrix with an odd number of sides and equal weights.
Importance for other functions in dynamicSDM To extract spatially buffered explanatory
variable data using dynamicSDM functions extract_buffered_coords() or extract_buffered_raster(), a “moving window” matrix specifying the neighbourhood of cells to include in the calculation is required.
For example, by using a three by three “moving window” matrix of equal weights, the explanatory variable would be calculated across the nine grid cells neighbouring the cell of interest and the cell of interest.
Why use a moving window matrix instead of circular buffer?
The benefit of using a “moving window” over calculating explanatory variable values across a set radius from each record co-ordinate, is that when generating projection rasters at high spatial and temporal resolution, these can be generated much faster as the “moving windows” standardise the calculation.
Function calculation
To calculate the “moving window” matrix size, the get_moving_window() function first calculates the circular area of interest, using the user-specified radius of interest and the equation for area of a circle.
This radius should be chosen to represent the radial distance from species occurrence record co-ordinates that the explanatory variable data might be relevant and impact species presence.
Then, the average grid cell area of the explanatory variable data (derived from user-provided spatial resolution and extent) is calculated. If spatial.res.degrees is given then spatial.ext
is required to calculate average cell area size. If spatial.res.metres is given then average cell area is calculated by squaring this value to get cell area in square metres.
Finally, the function then calculates the optimal “moving window” matrix that best matches circular area of interest with the “moving window” matrix area. The matrix of weights will have an odd number of sides.