[](https://github.com/ropensci/NLMR/actions)
[](https://app.codecov.io/gh/ropensci/NLMR)
[](https://cran.r-project.org/package=NLMR)
[](https://cran.r-project.org/package=NLMR)
[](https://github.com/ropensci/software-review/issues/188)
[](https://doi.org/10.1111/2041-210X.13076)
# NLMR
**NLMR** is an `R` package for simulating **n**eutral **l**andscape
**m**odels (NLM). Designed to be a generic framework like
[NLMpy](https://pypi.org/project/nlmpy/), it leverages the ability to
simulate the most common NLM that are described in the ecological
literature. **NLMR** builds on the advantages of the **terra** package
and returns all simulations as `SpatRaster` objects, thus ensuring
direct compatibility with common GIS tasks and a flexible and simple
usage. Furthermore, it simulates NLMs within a self-contained,
reproducible framework.
## Installation
NLMR is currently not available on CRAN. The only way to install NLMR at
the moment is:
``` r
# install.packages("remotes")
remotes::install_github("ropensci/NLMR")
```
## Example
Each neutral landscape model is simulated with a single function (all
starting with `nlm_`) in **NLMR**, e.g.:
``` r
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_displacememt <- NLMR::nlm_mpd(ncol = 100,
nrow = 100,
roughness = 0.61)
```
## Overview
**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):
| Function | description | reference |
|---|---|---|
| nlm_percolation | Binary landscapes from thresholded random draws. | Gardner et al. (1989) |
| nlm_neigh | Categorical landscapes shaped by neighbourhood effects. | Scherer et al. (2016) |
| nlm_randomcluster | Nearest-neighbour random clusters. | Saura and Martinez-Millan (2000) |
| nlm_randomrectangularcluster | Overlapping rectangular clusters. | Gustafson and Parker (1992) |
| nlm_gaussianfield | Spatially correlated Gaussian random fields. | Schlather et al. (2015) |
| nlm_curds | Recursive curdling with optional wheying. | O’Neill, Gardner, and Turner (1992); Keitt (2000) |
| nlm_fbm | Fractional Brownian motion surfaces. | Schlather et al. (2015) |
| nlm_mpd | Midpoint displacement surfaces. | Peitgen and Saupe (1988) |
| nlm_distancegradient | Distance gradients measured from a rectangular origin. | Etherington, Holland, and O’Sullivan (2015) |
| nlm_edgegradient | Directional gradients with a central peak. | Travis and Dytham (2004); Schlather et al. (2015) |
| nlm_planargradient | Linear gradients in a specified or random direction. | Palmer (1992) |
| nlm_random | Independent random values drawn for each cell. | With and Crist (1995) |
| nlm_mosaicfield | Mosaic random fields generated by repeated bisection. | Schlather et al. (2015) |
| nlm_mosaicgibbs | Inhibited point-pattern tessellations. | Gaucherel (2008), Method 2 |
| nlm_mosaictess | Voronoi tessellations from random seed points. | Gaucherel (2008), Method 1 |