get_moving_window {dynamicSDM}R Documentation

Generate a “moving window” matrix of optimal size


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.





a numeric value, the radius of interest in metres.


a numeric value, the spatial resolution in degrees of explanatory variable data.


a numeric value, the spatial resolution in metres of explanatory variable data.


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 "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

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.


get_moving_window(radial.distance = 100000, spatial.res.metres = 111320)

[Package dynamicSDM version 1.3.4 Index]