Title: | Simulating Neutral Landscape Models |
---|---|
Description: | Provides neutral landscape models (<doi:10.1007/BF02275262>, <http://sci-hub.tw/10.1007/bf02275262>). Neutral landscape models range from "hard" neutral models (completely random distributed), to "soft" neutral models (definable spatial characteristics) and generate landscape patterns that are independent of ecological processes. Thus, these patterns can be used as null models in landscape ecology. 'NLMR' combines a large number of algorithms from other published software for simulating neutral landscapes. The simulation results are obtained in a spatial data format (raster* objects from the 'raster' package) and can, therefore, be used in any sort of raster data operation that is performed with standard observation data. |
Authors: | Marco Sciaini [aut, cre] , Matthias Fritsch [aut], Maximilian Hesselbarth [aut], Craig Simpkins [aut] , Cédric Scherer [aut] , Sebastian Hanß [aut] , Laura Graham [rev] (Laura reviewed the package for rOpenSci, see https://github.com/ropensci/onboarding/issues/188), Jeffrey Hollister [rev] (Jeffrey reviewed the package for rOpenSci, see https://github.com/ropensci/onboarding/issues/188) |
Maintainer: | Marco Sciaini <[email protected]> |
License: | GPL-3 |
Version: | 1.1.1 |
Built: | 2024-12-19 06:27:28 UTC |
Source: | https://github.com/ropensci/NLMR |
Simulates a random curd neutral landscape model with optional wheys.
nlm_curds(curds, recursion_steps, wheyes = NULL, resolution = 1)
nlm_curds(curds, recursion_steps, wheyes = NULL, resolution = 1)
curds |
[ |
recursion_steps |
[ |
wheyes |
[ |
resolution |
[ |
Random curdling recursively subdivides the plane into blocks. At each level of the recursion, a fraction of the blocks are declared as habitat (value == TRUE) while the remaining blocks continue to be defined as matrix (value == FALSE) and enter the next recursive cycle.
The optional argument (wheyes
) allows wheys to be added, in which a set proportion of cells that were
declared matrix (value == FALSE) during recursion, are now set as habitat cells (value == TRUE).
If
the models resembles a binary random map.
Note that you can not set ncol and nrow with this landscape algorithm. The amount of cells and hence dimension of the raster is given by the vector product of the recursive steps.
raster
Keitt TH. 2000. Spectral representation of neutral landscapes. Landscape Ecology 15:479-493.
Szaro, Robert C., and David W. Johnston, eds. Biodiversity in managed landscapes: theory and practice. Oxford University Press, USA, 1996.
# simulate random curdling (random_curdling <- nlm_curds(curds = c(0.5, 0.3, 0.6), recursion_steps = c(32, 6, 2))) # simulate wheyed curdling (wheyed_curdling <- nlm_curds(curds = c(0.5, 0.3, 0.6), recursion_steps = c(32, 6, 2), wheyes = c(0.1, 0.05, 0.2))) ## Not run: # Visualize the NLMs landscapetools::show_landscape(random_curdling) landscapetools::show_landscape(wheyed_curdling) ## End(Not run)
# simulate random curdling (random_curdling <- nlm_curds(curds = c(0.5, 0.3, 0.6), recursion_steps = c(32, 6, 2))) # simulate wheyed curdling (wheyed_curdling <- nlm_curds(curds = c(0.5, 0.3, 0.6), recursion_steps = c(32, 6, 2), wheyes = c(0.1, 0.05, 0.2))) ## Not run: # Visualize the NLMs landscapetools::show_landscape(random_curdling) landscapetools::show_landscape(wheyed_curdling) ## End(Not run)
Simulates a distance-gradient neutral landscape model.
nlm_distancegradient(ncol, nrow, resolution = 1, origin, rescale = TRUE)
nlm_distancegradient(ncol, nrow, resolution = 1, origin, rescale = TRUE)
ncol |
[ |
nrow |
[ |
resolution |
[ |
origin |
[ |
rescale |
[ |
The function takes the number of columns and rows as input and creates a
RasterLayer
with the same extent. Origin
is a numeric vector of
xmin, xmax, ymin, ymax for a rectangle inside the raster from which the
distance is measured.
RasterLayer
nlm_edgegradient
,
nlm_planargradient
# simulate a distance gradient distance_gradient <- nlm_distancegradient(ncol = 100, nrow = 100, origin = c(20, 30, 10, 15)) ## Not run: # visualize the NLM landscapetools::show_landscape(distance_gradient) ## End(Not run)
# simulate a distance gradient distance_gradient <- nlm_distancegradient(ncol = 100, nrow = 100, origin = c(20, 30, 10, 15)) ## Not run: # visualize the NLM landscapetools::show_landscape(distance_gradient) ## End(Not run)
Simulates an edge-gradient neutral landscape model.
nlm_edgegradient(ncol, nrow, resolution = 1, direction = NA, rescale = TRUE)
nlm_edgegradient(ncol, nrow, resolution = 1, direction = NA, rescale = TRUE)
ncol |
[ |
nrow |
[ |
resolution |
[ |
direction |
[ |
rescale |
[ |
Simulates a linear gradient orientated on a specified or random direction that has a central peak running perpendicular to the gradient direction.
RasterLayer
Travis, J.M.J. & Dytham, C. (2004) A method for simulating patterns of habitat availability at static and dynamic range margins. Oikos, 104, 410–416.
nlm_distancegradient
,
nlm_planargradient
# simulate random curdling edge_gradient <- nlm_edgegradient(ncol = 100, nrow = 100, direction = 80) ## Not run: # visualize the NLM landscapetools::show_landscape(edge_gradient) ## End(Not run)
# simulate random curdling edge_gradient <- nlm_edgegradient(ncol = 100, nrow = 100, direction = 80) ## Not run: # visualize the NLM landscapetools::show_landscape(edge_gradient) ## End(Not run)
Creates a two-dimensional fractional Brownian motion neutral landscape model.
nlm_fbm( ncol, nrow, resolution = 1, fract_dim = 1, user_seed = NULL, rescale = TRUE, ... )
nlm_fbm( ncol, nrow, resolution = 1, fract_dim = 1, user_seed = NULL, rescale = TRUE, ... )
ncol |
[ |
nrow |
[ |
resolution |
[ |
fract_dim |
[ |
user_seed |
[ |
rescale |
[ |
... |
Other options to RandomFields::RFoptions, especially if using
a fractal dimension between ~ 1.6 and 1.9 one must set the option
|
Neutral landscapes are generated using fractional Brownian motion,
an extension of Brownian motion in which the amount of correlation between
steps is controlled by frac_dim
. A high value of frac_dim
produces a
relatively smooth, correlated surface while a low value produces a rough, uncorrelated one.
RasterLayer
Travis, J.M.J. & Dytham, C. (2004). A method for simulating patterns of habitat availability at static and dynamic range margins. Oikos , 104, 410–416.
Martin Schlather, Alexander Malinowski, Peter J. Menck, Marco Oesting, Kirstin Strokorb (2015). nlm_fBm. Journal of Statistical Software, 63(8), 1-25. URL http://www.jstatsoft.org/v63/i08/.
# simulate fractional brownian motion fbm_raster <- nlm_fbm(ncol = 20, nrow = 30, fract_dim = 0.8) ## Not run: # visualize the NLM landscapetools::show_landscape(fbm_raster) ## End(Not run)
# simulate fractional brownian motion fbm_raster <- nlm_fbm(ncol = 20, nrow = 30, fract_dim = 0.8) ## Not run: # visualize the NLM landscapetools::show_landscape(fbm_raster) ## End(Not run)
Simulates a spatially correlated random fields (Gaussian random fields) neutral landscape model.
nlm_gaussianfield( ncol, nrow, resolution = 1, autocorr_range = 10, mag_var = 5, nug = 0.2, mean = 0.5, user_seed = NULL, rescale = TRUE )
nlm_gaussianfield( ncol, nrow, resolution = 1, autocorr_range = 10, mag_var = 5, nug = 0.2, mean = 0.5, user_seed = NULL, rescale = TRUE )
ncol |
[ |
nrow |
[ |
resolution |
[ |
autocorr_range |
[ |
mag_var |
[ |
nug |
[ |
mean |
[ |
user_seed |
[ |
rescale |
[ |
Gaussian random fields are a collection of random numbers on a spatially discrete set of coordinates (landscape raster). Natural sciences often apply them with spatial autocorrelation, meaning that objects which distant are more distinct from one another than they are to closer objects.
Kéry & Royle (2016) Applied Hierarchical Modeling in Ecology Chapter 20
# simulate random gaussian field gaussian_field <- nlm_gaussianfield(ncol = 90, nrow = 90, autocorr_range = 60, mag_var = 8, nug = 5) ## Not run: # visualize the NLM landscapetools::show_landscape(gaussian_field) ## End(Not run)
# simulate random gaussian field gaussian_field <- nlm_gaussianfield(ncol = 90, nrow = 90, autocorr_range = 60, mag_var = 8, nug = 5) ## Not run: # visualize the NLM landscapetools::show_landscape(gaussian_field) ## End(Not run)
Simulates a mosaic random field neutral landscape model.
nlm_mosaicfield( ncol, nrow, resolution = 1, n = 20, mosaic_mean = 0.5, mosaic_sd = 0.5, collect = FALSE, infinit = FALSE, rescale = TRUE )
nlm_mosaicfield( ncol, nrow, resolution = 1, n = 20, mosaic_mean = 0.5, mosaic_sd = 0.5, collect = FALSE, infinit = FALSE, rescale = TRUE )
ncol |
[ |
nrow |
[ |
resolution |
[ |
n |
[ |
mosaic_mean |
[ |
mosaic_sd |
[ |
collect |
[ |
infinit |
[ |
rescale |
[ |
RasterLayer or List with RasterLayer/s and/or RasterBrick
Schwab, Dimitri, Martin Schlather, and Jürgen Potthoff. "A general class of
mosaic random fields." arXiv preprint arXiv:1709.01441 (2017).
Baddeley, Adrian, Ege Rubak, and Rolf Turner. Spatial point patterns:
methodology and applications with R. CRC Press, 2015.
# simulate mosaic random field mosaic_field <- nlm_mosaicfield(ncol = 100, nrow = 200, n = NA, infinit = TRUE, collect = FALSE) ## Not run: # visualize the NLM landscapetools::show_landscape(mosaic_field) ## End(Not run)
# simulate mosaic random field mosaic_field <- nlm_mosaicfield(ncol = 100, nrow = 200, n = NA, infinit = TRUE, collect = FALSE) ## Not run: # visualize the NLM landscapetools::show_landscape(mosaic_field) ## End(Not run)
Simulate a neutral landscape model using the Gibbs algorithm introduced in Gaucherel (2008).
nlm_mosaicgibbs( ncol, nrow, resolution = 1, germs, R, patch_classes, rescale = TRUE )
nlm_mosaicgibbs( ncol, nrow, resolution = 1, germs, R, patch_classes, rescale = TRUE )
ncol |
[ |
nrow |
[ |
resolution |
[ |
germs |
[ |
R |
[ |
patch_classes |
[ |
rescale |
[ |
nlm_mosaicgibbs
offers the second option of simulating a neutral landscape model
described in Gaucherel (2008).
The method works in principal like the tessellation method (nlm_mosaictess
),
but instead of a random point pattern the algorithm fits a simulated realization of the Strauss
process. The Strauss process starts with a given number of points and
uses a minimization approach to fit a point pattern with a given interaction
parameter (0 - hardcore process; 1 - Poisson process) and interaction radius
(distance of points/germs being apart).
RasterLayer
Gaucherel, C. (2008) Neutral models for polygonal landscapes with linear networks. Ecological Modelling, 219, 39 - 48.
# simulate polygonal landscapes mosaicgibbs <- nlm_mosaicgibbs(ncol = 40, nrow = 30, germs = 20, R = 0.02, patch_classes = 12) ## Not run: # visualize the NLM landscapetools::show_landscape(mosaicgibbs) ## End(Not run)
# simulate polygonal landscapes mosaicgibbs <- nlm_mosaicgibbs(ncol = 40, nrow = 30, germs = 20, R = 0.02, patch_classes = 12) ## Not run: # visualize the NLM landscapetools::show_landscape(mosaicgibbs) ## End(Not run)
Simulate a neutral landscape model using the tesselation approach introduced in Gaucherel (2008).
nlm_mosaictess(ncol, nrow, resolution = 1, germs, rescale = TRUE)
nlm_mosaictess(ncol, nrow, resolution = 1, germs, rescale = TRUE)
ncol |
[ |
nrow |
[ |
resolution |
[ |
germs |
[ |
rescale |
[ |
nlm_mosaictess
offers the first option of simulating a neutral landscape model
described in Gaucherel (2008). It generates a random point pattern (germs)
with an independent distribution and uses the Voronoi tessellation to simulate mosaic landscapes.
RasterLayer
Gaucherel, C. (2008) Neutral models for polygonal landscapes with linear networks. Ecological Modelling, 219, 39 - 48.
# simulate polygonal landscapes mosaictess <- nlm_mosaictess(ncol = 30, nrow = 60, germs = 200) ## Not run: # visualize the NLM landscapetools::show_landscape(mosaictess) ## End(Not run)
# simulate polygonal landscapes mosaictess <- nlm_mosaictess(ncol = 30, nrow = 60, germs = 200) ## Not run: # visualize the NLM landscapetools::show_landscape(mosaictess) ## End(Not run)
Simulates a midpoint displacement neutral landscape model.
nlm_mpd( ncol, nrow, resolution = 1, roughness = 0.5, rand_dev = 1, torus = FALSE, rescale = TRUE, verbose = TRUE )
nlm_mpd( ncol, nrow, resolution = 1, roughness = 0.5, rand_dev = 1, torus = FALSE, rescale = TRUE, verbose = TRUE )
ncol |
[ |
nrow |
[ |
resolution |
[ |
roughness |
[ |
rand_dev |
[ |
torus |
[ |
rescale |
[ |
verbose |
[ |
The algorithm is a direct implementation of the midpoint displacement algorithm. It performs the following steps:
Initialization: Determine the smallest fit of
max(ncol, nrow)
in n^2 + 1 and assign value to n.
Setup matrix of size (n^2 + 1)*(n^2 + 1).
Afterwards, assign a random value to the four corners of the matrix.
Square Step: For each square in the matrix, assign the average of the four corner points plus a random value to the midpoint of that square.
Diamond Step: For each diamond in the matrix, assign the average of the four corner points plus a random value to the midpoint of that diamond.
At each iteration the roughness, an approximation to common Hurst exponent, is reduced.
RasterLayer
https://en.wikipedia.org/wiki/Diamond-square_algorithm
# simulate midpoint displacement midpoint_displacememt <- nlm_mpd(ncol = 100, nrow = 100, roughness = 0.3) ## Not run: # visualize the NLM landscapetools::show_landscape(midpoint_displacememt) ## End(Not run)
# simulate midpoint displacement midpoint_displacememt <- nlm_mpd(ncol = 100, nrow = 100, roughness = 0.3) ## Not run: # visualize the NLM landscapetools::show_landscape(midpoint_displacememt) ## End(Not run)
Create a neutral landscape model with categories and clustering based on neighborhood characteristics.
nlm_neigh( ncol, nrow, resolution = 1, p_neigh, p_empty, categories = 3, neighbourhood = 4, proportions = NA, rescale = TRUE )
nlm_neigh( ncol, nrow, resolution = 1, p_neigh, p_empty, categories = 3, neighbourhood = 4, proportions = NA, rescale = TRUE )
ncol |
[ |
nrow |
[ |
resolution |
[ |
p_neigh |
[ |
p_empty |
[ |
categories |
[ |
neighbourhood |
[ |
proportions |
[ |
rescale |
[ |
The algorithm draws a random cell and turns it into a given category based on
the probabilities p_neigh
and p_empty
, respectively. The decision is
based on the probability p_neigh
, if there is any cell in the Moore- (8 cells) or
Von-Neumann-neighborhood (4 cells), otherwise it is based on p_empty
. To create
clustered neutral landscape models, p_empty
should be (significantly) smaller than
p_neigh
. By default, the Von-Neumann-neighborhood is used to check adjacent
cells. The algorithm starts with the highest categorical value. If the
proportion of cells with this value is reached, the categorical value is
reduced by 1. By default, a uniform distribution of the categories is
applied.
RasterLayer
Scherer, Cédric, et al. "Merging trait-based and individual-based modelling: An animal functional type approach to explore the responses of birds to climatic and land use changes in semi-arid African savannas." Ecological Modelling 326 (2016): 75-89.
# simulate neighborhood model neigh_raster <- nlm_neigh(ncol = 50, nrow = 50, p_neigh = 0.7, p_empty = 0.1, categories = 5, neighbourhood = 4) ## Not run: # visualize the NLM landscapetools::show_landscape(neigh_raster) ## End(Not run)
# simulate neighborhood model neigh_raster <- nlm_neigh(ncol = 50, nrow = 50, p_neigh = 0.7, p_empty = 0.1, categories = 5, neighbourhood = 4) ## Not run: # visualize the NLM landscapetools::show_landscape(neigh_raster) ## End(Not run)
Generates a random percolation neutral landscape model.
nlm_percolation(ncol, nrow, resolution = 1, prob = 0.5)
nlm_percolation(ncol, nrow, resolution = 1, prob = 0.5)
ncol |
[ |
nrow |
[ |
resolution |
[ |
prob |
[ |
The simulation of a random percolation map is accomplished in two steps:
Initialization: Setup matrix of size (ncol
*nrow
)
Map generation: For each cell in the matrix a single uniformly
distributed random number is generated and tested against a probability
prob
. If the random number is smaller than prob
, the cell is set to
TRUE - if it is higher the cell is set to FALSE.
RasterLayer
1. Gardner RH, O'Neill R V, Turner MG, Dale VH. 1989. Quantifying scale-dependent effects of animal movement with simple percolation models. Landscape Ecology 3:217 - 227.
2. Gustafson, E.J. & Parker, G.R. (1992) Relationships between landcover proportion and indices of landscape spatial pattern. Landscape Ecology , 7, 101 - 110.
# simulate percolation model percolation <- nlm_percolation(ncol = 100, nrow = 100, prob = 0.5) ## Not run: # visualize the NLM landscapetools::show_landscape(percolation) ## End(Not run)
# simulate percolation model percolation <- nlm_percolation(ncol = 100, nrow = 100, prob = 0.5) ## Not run: # visualize the NLM landscapetools::show_landscape(percolation) ## End(Not run)
Simulates a planar gradient neutral landscape model.
nlm_planargradient(ncol, nrow, resolution = 1, direction = NA, rescale = TRUE)
nlm_planargradient(ncol, nrow, resolution = 1, direction = NA, rescale = TRUE)
ncol |
[ |
nrow |
[ |
resolution |
[ |
direction |
[ |
rescale |
[ |
Simulates a linear gradient sloping in a specified or random direction.
RasterLayer
Palmer, M.W. (1992) The coexistence of species in fractal landscapes. The American Naturalist, 139, 375 - 397.
nlm_distancegradient
,
nlm_edgegradient
# simulate planar gradient planar_gradient <- nlm_planargradient(ncol = 200, nrow = 200) ## Not run: # visualize the NLM landscapetools::show_landscape(planar_gradient) ## End(Not run)
# simulate planar gradient planar_gradient <- nlm_planargradient(ncol = 200, nrow = 200) ## Not run: # visualize the NLM landscapetools::show_landscape(planar_gradient) ## End(Not run)
Simulates a spatially random neutral landscape model with values drawn a uniform distribution.
nlm_random(ncol, nrow, resolution = 1, rescale = TRUE)
nlm_random(ncol, nrow, resolution = 1, rescale = TRUE)
ncol |
[ |
nrow |
[ |
resolution |
[ |
rescale |
[ |
The function takes the number of columns and rows as input and creates a
RasterLayer with the same extent. Each raster cell is randomly assigned a
value between 0 and 1 drawn from an uniform distribution (runif(1,0,1)
).
RasterLayer
# simulate spatially random model random <- nlm_random(ncol = 200, nrow = 100) ## Not run: # visualize the NLM landscapetools::show_landscape(random) ## End(Not run)
# simulate spatially random model random <- nlm_random(ncol = 200, nrow = 100) ## Not run: # visualize the NLM landscapetools::show_landscape(random) ## End(Not run)
Simulates a random cluster nearest-neighbour neutral landscape.
nlm_randomcluster( ncol, nrow, resolution = 1, p, ai = c(0.5, 0.5), neighbourhood = 4, rescale = TRUE )
nlm_randomcluster( ncol, nrow, resolution = 1, p, ai = c(0.5, 0.5), neighbourhood = 4, rescale = TRUE )
ncol |
[ |
nrow |
[ |
resolution |
[ |
p |
[ |
ai |
Vector with the cluster type distribution (percentages of occupancy). This directly controls the number of types via the given length. |
neighbourhood |
[ |
rescale |
[ |
This is a direct implementation of steps A - D of the modified random clusters algorithm by Saura & Martínez-Millán (2000), which creates naturalistic patchy patterns.
Raster with random values ranging from 0-1.
Saura, S. & Martínez-Millán, J. (2000) Landscape patterns simulation with a modified random clusters method. Landscape Ecology, 15, 661 – 678.
# simulate random clustering random_cluster <- nlm_randomcluster(ncol = 30, nrow = 30, p = 0.4, ai = c(0.25, 0.25, 0.5)) ## Not run: # visualize the NLM landscapetools::show_landscape(random_cluster) ## End(Not run)
# simulate random clustering random_cluster <- nlm_randomcluster(ncol = 30, nrow = 30, p = 0.4, ai = c(0.25, 0.25, 0.5)) ## Not run: # visualize the NLM landscapetools::show_landscape(random_cluster) ## End(Not run)
Simulates a random rectangular clusters neutral landscape model with values ranging 0-1.
nlm_randomrectangularcluster( ncol, nrow, resolution = 1, minl, maxl, rescale = TRUE )
nlm_randomrectangularcluster( ncol, nrow, resolution = 1, minl, maxl, rescale = TRUE )
ncol |
[ |
nrow |
[ |
resolution |
[ |
minl |
[ |
maxl |
[ |
rescale |
[ |
The random rectangular cluster algorithm starts to fill a raster randomly
with rectangles defined by minl
and maxl
until the surface
of the landscape is completely covered.
This is one type of realisation of a "falling/dead leaves" algorithm,
for more details see Galerne & Gousseau (2012).
RasterLayer
Gustafson, E.J. & Parker, G.R. (1992). Relationships between landcover proportion and indices of landscape spatial pattern. Landscape ecology, 7, 101–110. Galerne B. & Gousseau Y. (2012). The Transparent Dead Leaves Model. Advances in Applied Probability, Applied Probability Trust, 44, 1–20.
# simulate random rectangular cluster randomrectangular_cluster <- nlm_randomrectangularcluster(ncol = 50, nrow = 30, minl = 5, maxl = 10) ## Not run: # visualize the NLM landscapetools::show_landscape(randomrectangular_cluster) ## End(Not run)
# simulate random rectangular cluster randomrectangular_cluster <- nlm_randomrectangularcluster(ncol = 50, nrow = 30, minl = 5, maxl = 10) ## Not run: # visualize the NLM landscapetools::show_landscape(randomrectangular_cluster) ## End(Not run)