neutralLandscapeMap: Produce a neutral (random) landscape raster

View source: R/initialize.R

neutralLandscapeMapR Documentation

Produce a neutral (random) landscape raster

Description

Generates a SpatRaster of randomly-varying values on the same grid as a template raster x, using a built-in Gaussian-smoothed random field with no extra package dependencies.

Usage

neutralLandscapeMap(
  x,
  pad = 10L,
  type = "gaussian",
  smooth = 3L,
  rescale = TRUE,
  ...
)

Arguments

x

A SpatRaster (or RasterLayer) to use as a template for the grid and CRS.

pad

Integer. Number of cells by which to pad x internally; the padding is cropped from the result.

type

Character. Only "gaussian" (the default) is supported.

smooth

Half-width (in cells) of the smoothing kernel; larger values produce smoother landscapes with longer-range autocorrelation.

rescale

If TRUE (default), rescale output values to ⁠[0, 1]⁠.

...

Currently ignored; accepted for backwards compatibility.

Details

The "gaussian" generator fills a padded grid with i.i.d. normal noise, then smooths it with a square mean kernel of size 2 * smooth + 1. The result is a roughly Gaussian random field, suitable for sample modules, demos, and tests.

Value

A SpatRaster (or RasterLayer, matching x) with the same extent, resolution, and CRS as x, filled with randomly-generated values.

Examples


  library(terra)
  nx <- ny <- 100L
  r <- rast(nrows = ny, ncols = nx,
            xmin = -nx/2, xmax = nx/2,
            ymin = -ny/2, ymax = ny/2)

  map_default <- neutralLandscapeMap(r)
  if (interactive()) plot(map_default)

  ## Tweak smoothness:
  map_rough  <- neutralLandscapeMap(r, smooth = 1)
  map_smooth <- neutralLandscapeMap(r, smooth = 8)


SpaDES.tools documentation built on Aug. 29, 2026, 1:07 a.m.