Skip to contents

Renames and rescales output from python_focal_run() as needed to match expected inputs for species distribution models (SDMs). Includes options to mask by another raster and fill missing values with zero.


  overwrite = FALSE,
  mask = NULL,
  cover = FALSE


pathin, SDM, landscape_name, scale

Character strings defining the filepath (pathin/SDM/landscape_name,scale) containing input rasters to be processed, such as those created from running python_focal_run()


Character string defining the filepath (pathout/SDM/landscape_name) where output rasters should be written


Logical; passed to terra::writeRaster()


Optional SpatRaster or character string giving the filepath to a raster that should be used to mask the output, e.g. a study area boundary


Logical; default is FALSE. If TRUE, mask must not be NULL; See Details.


Nothing returned to R environment. Writes rasters to pathout for each land cover class.


Function expects source files to be in a directory structure created by python_focal_run(), which is also used to inform the final processing steps: pathin/SDM/landscape_name/scale. All .tif files in this source directory will be read in, and optionally masked by the raster at mask. If cover = TRUE, pixels in mask with a value of 1 will also be replaced with a value of 0, and passed to terra::cover() to fill in missing values in source data with zero.

If SDM = "riparian", pixel counts are converted to a proportion of the total number of cells expected within the buffer distance represented by scale, and the scale is appended to the predictor name in the format "_50" or "_2000", as expected by the riparian SDMs.

If SDM = "waterbird_fall" or SDM = "waterbird_win", the scale is appended to the predictor name in the format "_2k", "_5k", or "_10k", as expected by the waterbird SDMs.

The final rasters are then written to the directory pathout/SDM/landscape_name, which will be created if it doesn't yet exist.


# See vignette