Skip to contents

Adding padding to raster

Usage

pad_raster(
  landscape,
  pad_raster_value = -999,
  pad_raster_cells = 1,
  global = FALSE,
  return_raster = TRUE,
  to_disk = getOption("to_disk", default = FALSE)
)

Arguments

landscape

A categorical raster object: SpatRaster; Raster* Layer, Stack, Brick; stars or a list of SpatRasters.

pad_raster_value

Value of cells added

pad_raster_cells

Number of rows and columns added

global

If TRUE, NAs within the landscape are replace with the value; if FALSE only padding around the raster is added.

return_raster

If false, matrix is returned

to_disk

Logical argument, if FALSE results of get_patches are hold in memory. If true, pad_raster writes temporary files and hence, does not hold everything in memory. Can be set with a global option, e.g. option(to_disk = TRUE).

Value

raster

Details

Adds equally (in all four directions) additional cells around the raster

Examples

landscape <- terra::rast(landscapemetrics::landscape)
pad_raster(landscape, pad_raster_value = -1, pad_raster_cells = 2)
#> $layer_1
#> class       : SpatRaster 
#> dimensions  : 34, 34, 1  (nrow, ncol, nlyr)
#> resolution  : 1, 1  (x, y)
#> extent      : -2, 32, -2, 32  (xmin, xmax, ymin, ymax)
#> coord. ref. :  
#> source(s)   : memory
#> name        : lyr.1 
#> min value   :    -1 
#> max value   :     3 
#>