Simulate Neutral Landscape Models

tutorial rstats spatial modelling

Learn how to use the {NLMR} R package to simulate neutral landscape models (NLMs), a common set of various null models for spatial analysis and as input for spatially-explicit, generic models.

Cedric Scherer https://cedricscherer.com (IZW Berlin)https://ecodynizw.github.io/
2021-08-06

The {NLMR} R package to simulate neutral landscape models (NLM). Designed to be a generic framework like NLMpy, it leverages the ability to simulate the most common NLM that are described in the ecological literature.

If you want to learn more about the {NLMR} package and the accompanying {landscapetools} package, check the publication Sciaini, Fritsch, Scherer 6 Simpkins (2019) Methods in Ecology and Evolution.

Installation

Install the release version from CRAN:

or the development version from Github, along with two packages that are needed for the generation of random fields:

install.packages("remotes")
remotes::install_github("cran/RandomFieldsUtils")
remotes::install_github("cran/RandomFields")
remotes::install_github("ropensci/NLMR")

Usage

Each neutral landscape models is simulated with a single function (all starting with nlm_) in NLMR, e.g.:

random_cluster <- NLMR::nlm_randomcluster(
  nrow = 100,
  ncol = 100,
  p    = 0.5,
  ai   = c(0.3, 0.6, 0.1),
  rescale = FALSE
)

random_curdling <- NLMR::nlm_curds(
  curds = c(0.5, 0.3, 0.6),
  recursion_steps = c(32, 6, 2)
)

midpoint_displacement <- NLMR::nlm_mpd(
  ncol = 100,
  nrow = 100,
  roughness = 0.61
)

{NLMR} supplies 15 NLM algorithms, with several options to simulate derivatives of them. The algorithms differ from each other in spatial auto-correlation, from no auto-correlation (random NLM) to a constant gradient (planar gradients).

The package builds on the advantages of the raster package and returns all simulation as RasterLayer objects, thus ensuring a direct compatibility to common GIS tasks and a flexible and simple usage:

class(random_cluster)
[1] "RasterLayer"
attr(,"package")
[1] "raster"
random_cluster
class      : RasterLayer 
dimensions : 100, 100, 10000  (nrow, ncol, ncell)
resolution : 1, 1  (x, y)
extent     : 0, 100, 0, 100  (xmin, xmax, ymin, ymax)
crs        : NA 
source     : memory
names      : clumps 
values     : 1, 3  (min, max)

Visualization

The {landscapetools} package provides a function show_landscape that was developed to plot raster objects and help users to adhere to some standards concerning color scales and typography. This means for example that by default the viridis color scale is applied (and you can pick others from the {viridis} package, too).

#install.packages("landscapetools")

## plotting continuous values
landscapetools::show_landscape(random_cluster)
## plotting discrete values
landscapetools::show_landscape(random_curdling, discrete = TRUE)
## using another viridis palette
landscapetools::show_landscape(midpoint_displacement, viridis_scale = "magma")

Citation

For attribution, please cite this work as

Scherer (2021, Aug. 6). Ecological Dynamics: Simulate Neutral Landscape Models. Retrieved from https://ecodynizw.github.io/posts/nlmr/

BibTeX citation

@misc{scherer2021simulate,
  author = {Scherer, Cedric},
  title = {Ecological Dynamics: Simulate Neutral Landscape Models},
  url = {https://ecodynizw.github.io/posts/nlmr/},
  year = {2021}
}