Terraflux Terraflux
Download

Neutral landscape models

19 operators. Inputs marked required must be connected or given; the others have defaults.

nlm.binarize#

Habitat (2) and matrix (1) of a map (NLMR's util_binarize): the share of habitat given, the cells with the highest values. Several shares give a stack, a map each.

InputTypeWhat it is
maprequiredmapthe values (a neutral landscape)
OutputTypeWhat it is
mapany1 matrix, 2 habitat: a map, or a stack by share
SettingTypeWhat it is
breaksrequiredanythe share of habitat, in [0, 1], or several

nlm.classify#

Classes 1, 2... of a map (NLMR's util_classify): by the weights, each class's share of the cells (the cells sorted, the boundaries at the cumulative shares); by a real landscape's shares of its values; or in n classes by Jenks's natural breaks.

InputTypeWhat it is
maprequiredmapthe values (a neutral landscape)
realmapa real landscape whose classes' shares to take
OutputTypeWhat it is
classesmapthe classes 1, 2...
SettingTypeWhat it is
nintegerthe classes, by natural breaks
weightsanyeach class's share of the cells (null for an even share of what the others leave)
mask_valuenumberthe real landscape's value to leave out

nlm.curds#

A hierarchical binary map (NLMR's nlm_curds, curdling): at each level every cell splits into steps x steps cells and a share of them becomes matrix (0), the rest habitat (1); with wheyes, a share of the matrix turns back to habitat (wheyed curdling). Its side is the product of the steps.

OutputTypeWhat it is
mapmap1 habitat, 0 matrix
SettingTypeWhat it is
curdsrequiredanyeach level's share of matrix cells, e.g. [0.5, 0.3, 0.6]
stepsrequiredanyeach level's split, e.g. [32, 6, 2]
wheyesanyeach level's share of matrix turned to habitat
resolutionnumberthe cells' side (default 1)
seedintegerthe seed of R's generator (default 1): NLMR's map for it

nlm.distance_gradient#

The distance of every cell to a rectangle of cells (NLMR's nlm_distancegradient). As NLMR's (the default): terra's distance, on a lon/lat grid of 1 degree cells for maps up to 360 x 90 (metres on the sphere), else GDAL's proximity in cells; otherwise the exact distance between the cells' centres, in map units.

InputTypeWhat it is
likemapa map whose grid to draw on (else rows x columns)
OutputTypeWhat it is
mapmapthe distances
SettingTypeWhat it is
rowsintegerrows (default 256)
columnsintegercolumns (default 256)
resolutionnumberthe cells' side (default 1)
seedintegerthe seed of R's generator (default 1): NLMR's map for it
rescaleboolrescale the values to 0-1 (default true)
originrequiredanythe rectangle, 1-based and inclusive: NLMR's [row from, row to, column from, column to] (as its checks: the second at most the columns and the fourth at most the rows); without NLMR's, [column from, column to, row from, row to]
nlmr_compatboolNLMR's distances and origin (default true)

nlm.edge_gradient#

A gradient that peaks in the middle of the map and falls to its edges along a direction (NLMR's nlm_edgegradient): the planar gradient rescaled and folded around 0.5.

InputTypeWhat it is
likemapa map whose grid to draw on (else rows x columns)
OutputTypeWhat it is
mapmapthe gradient
directionnumberits direction, in degrees
SettingTypeWhat it is
rowsintegerrows (default 256)
columnsintegercolumns (default 256)
resolutionnumberthe cells' side (default 1)
seedintegerthe seed of R's generator (default 1): NLMR's map for it
rescaleboolrescale the values to 0-1 (default true)
directionnumberin degrees, 0 north to 90 east (default: a uniform draw from 0 to 360 with the seed)

nlm.fbm#

A fractal surface from 0 to 1 (NLMR's nlm_fbm, fractional Brownian motion): rough for a small fractal dimension, smooth for a large one (2 is a plane).

InputTypeWhat it is
likemapa map whose grid to draw on (else rows x columns)
OutputTypeWhat it is
mapmapthe surface, 0 to 1
SettingTypeWhat it is
rowsintegerrows (default 256)
columnsintegercolumns (default 256)
resolutionnumberthe cells' side (default 1)
seedintegerthe seed of R's generator (default 1): NLMR's map for it
dimensionnumberthe fractal dimension, in (0, 2] (default 1)

nlm.gaussian_field#

A smooth random surface from 0 to 1 (NLMR's nlm_gaussianfield): a Gaussian field whose autocorrelation fades over the range given. A driver, a suitability or an elevation to try a model on; reclassified, a map of classes.

InputTypeWhat it is
likemapa map whose grid to draw on (else rows x columns)
OutputTypeWhat it is
mapmapthe field, 0 to 1
SettingTypeWhat it is
rowsintegerrows (default 256)
columnsintegercolumns (default 256)
resolutionnumberthe cells' side (default 1)
seedintegerthe seed of R's generator (default 1): NLMR's map for it
rangenumberthe range of the autocorrelation, in cells (default 10)
variancenumberof the autocorrelated part (default 5)
nuggetnumberthe variance of the noise without structure (default 0.2)

nlm.merge#

Landscapes merged (NLMR's util_merge): the primary plus the sum of the secondary ones times the scaling, e.g. a gradient with noise on it.

InputTypeWhat it is
primaryrequiredmapthe primary landscape
secondaryrequiredanya map or a stack of maps on its grid
OutputTypeWhat it is
mapmapthe merged landscape
SettingTypeWhat it is
rescaleboolrescale the values to 0-1 (default true)
scalingnumberof the secondary landscapes (default 1)

nlm.mosaic_field#

A mosaic random field (NLMR's nlm_mosaicfield, spatstat's rMosaicField): the sum of n mosaics, each a Poisson line tessellation with a normal value per tile; optionally every step's sum and the infinite field (a log-Gaussian Cox process).

InputTypeWhat it is
likemapa map whose grid to draw on (else rows x columns)
OutputTypeWhat it is
mapmapthe sum of the n mosaics
stepsstackthe sum after each step (collect)
infinitmapthe infinite field (infinit)
SettingTypeWhat it is
rowsintegerrows (default 256)
columnsintegercolumns (default 256)
resolutionnumberthe cells' side (default 1)
seedintegerthe seed of R's generator (default 1): NLMR's map for it
rescaleboolrescale the values to 0-1 (default true)
nintegerthe mosaics (default 20; 0 for only the infinite field)
meannumberof the tiles' values (default 0.5)
sdnumberof the tiles' values (default 0.5)
collectboolevery step's sum too (default false)
infinitboolthe infinite field too (default false)
nlmr_compatboolNLMR's quirks (default true): its steps rescaled with the first's range

nlm.mosaic_gibbs#

A Voronoi mosaic of classes from germs kept apart (NLMR's nlm_mosaicgibbs): spatstat's rSSI germs at least R apart, each with a class 1..patch_classes, every cell the class of its nearest germ. As NLMR (nlmr_compat, the default) the k-th class goes to the k-th Voronoi cell in the order GEOS lists them (GEOS 3.11 or later, next to GDAL); else each germ keeps its own class.

InputTypeWhat it is
likemapa map whose grid to draw on (else rows x columns)
OutputTypeWhat it is
mapmapthe mosaic
SettingTypeWhat it is
rowsintegerrows (default 256)
columnsintegercolumns (default 256)
resolutionnumberthe cells' side (default 1)
seedintegerthe seed of R's generator (default 1): NLMR's map for it
rescaleboolrescale the values to 0-1 (default true)
germsrequiredintegerhow many germs
nlmr_compatboolNLMR's assignment of the values to the Voronoi cells by GEOS's order (default true)
rrequirednumberthe shortest distance between germs, in cells
patch_classesrequiredintegerthe classes

nlm.mosaic_tess#

A Voronoi mosaic of random values (NLMR's nlm_mosaictess): random germs (sf's st_sample), a uniform value each, every cell the value of its nearest germ. As NLMR (nlmr_compat, the default) the k-th value goes to the k-th Voronoi cell in the order GEOS lists them (GEOS 3.11 or later, next to GDAL) and the values are floats, as terra::rasterize writes them; else each germ keeps its own value, in double precision.

InputTypeWhat it is
likemapa map whose grid to draw on (else rows x columns)
OutputTypeWhat it is
mapmapthe mosaic
SettingTypeWhat it is
rowsintegerrows (default 256)
columnsintegercolumns (default 256)
resolutionnumberthe cells' side (default 1)
seedintegerthe seed of R's generator (default 1): NLMR's map for it
rescaleboolrescale the values to 0-1 (default true)
germsrequiredintegerhow many germs
nlmr_compatboolNLMR's assignment of the values to the Voronoi cells by GEOS's order (default true)

nlm.mpd#

A fractal surface by midpoint displacement (NLMR's nlm_mpd, the diamond-square algorithm): each step halves the cells and displaces the midpoints by a deviation that shrinks with the roughness. NLMR's grid (the default) is the odd side above the larger dimension, less its border: it may differ from the size asked for (a warning says so).

InputTypeWhat it is
likemapa map whose grid to draw on (else rows x columns)
OutputTypeWhat it is
mapmapthe surface
SettingTypeWhat it is
rowsintegerrows (default 256)
columnsintegercolumns (default 256)
resolutionnumberthe cells' side (default 1)
seedintegerthe seed of R's generator (default 1): NLMR's map for it
rescaleboolrescale the values to 0-1 (default true)
roughnessnumberin [0, 1]: how fast the deviation shrinks (0.5)
deviationnumberthe first step's deviation (default 1)
torusboolwrap the edges around (default false)
nlmr_compatboolNLMR's grid (default true)

nlm.neigh#

A map of categories grown by neighbourhood (NLMR's nlm_neigh): cells are filled one at a time, with the category of their neighbours (probability p_neigh) or, around empty ones, at random (p_empty), until each category has its share. Categories 0, 1...

InputTypeWhat it is
likemapa map whose grid to draw on (else rows x columns)
OutputTypeWhat it is
mapmapthe categories
SettingTypeWhat it is
rowsintegerrows (default 256)
columnsintegercolumns (default 256)
resolutionnumberthe cells' side (default 1)
seedintegerthe seed of R's generator (default 1): NLMR's map for it
rescaleboolrescale the values to 0-1 (default true)
p_neighrequirednumberthe probability of a cell with filled neighbours, [0, 1]
p_emptyrequirednumberthe probability of a cell without, [0, 1]
categoriesintegerhow many (default 3)
neighbourhoodinteger4 (default) or 8 neighbours
proportionsanyeach category's share of the cells, summing to 1 (default equal shares)

nlm.percolation#

A random binary map (NLMR's nlm_percolation): each cell is 1 with the probability given (a uniform draw below it, by column), else 0.

InputTypeWhat it is
likemapa map whose grid to draw on (else rows x columns)
OutputTypeWhat it is
mapmap1 and 0
SettingTypeWhat it is
rowsintegerrows (default 256)
columnsintegercolumns (default 256)
resolutionnumberthe cells' side (default 1)
seedintegerthe seed of R's generator (default 1): NLMR's map for it
probnumberthe probability of a 1, in [0, 1] (default 0.5)

nlm.planar_gradient#

A linear gradient across the map along a direction (NLMR's nlm_planargradient): eastness times the column plus southness times the row.

InputTypeWhat it is
likemapa map whose grid to draw on (else rows x columns)
OutputTypeWhat it is
mapmapthe gradient
directionnumberits direction, in degrees
SettingTypeWhat it is
rowsintegerrows (default 256)
columnsintegercolumns (default 256)
resolutionnumberthe cells' side (default 1)
seedintegerthe seed of R's generator (default 1): NLMR's map for it
rescaleboolrescale the values to 0-1 (default true)
directionnumberin degrees, 0 north to 90 east (default: a uniform draw from 0 to 360 with the seed)

nlm.random#

Spatially random values (NLMR's nlm_random): a uniform draw for every cell, by column as R fills a matrix. The null model of a landscape without structure.

InputTypeWhat it is
likemapa map whose grid to draw on (else rows x columns)
OutputTypeWhat it is
mapmapthe values (0 to 1)
SettingTypeWhat it is
rowsintegerrows (default 256)
columnsintegercolumns (default 256)
resolutionnumberthe cells' side (default 1)
seedintegerthe seed of R's generator (default 1): NLMR's map for it
rescaleboolrescale the values to 0-1 (default true)

nlm.random_cluster#

A map of patches of classes 1, 2... (NLMR's nlm_randomcluster, Saura & Martínez-Millán 2000): a share p of the cells grows into clusters, each of a class drawn with the weights, and the rest takes its neighbours' class. A forest map to try MSPA or a land change model on. The weights give the shares only roughly: the clusters are classed as wholes, so with few large clusters (p above about 0.59, the percolation threshold, where one cluster spans the map) one class may take most of it.

InputTypeWhat it is
likemapa map whose grid to draw on (else rows x columns)
OutputTypeWhat it is
mapmapthe classes 1, 2...
SettingTypeWhat it is
rowsintegerrows (default 256)
columnsintegercolumns (default 256)
resolutionnumberthe cells' side (default 1)
seedintegerthe seed of R's generator (default 1): NLMR's map for it
pnumberthe share of cells in clusters, up to 1 (default 0.5)
weightsanythe classes' weights, their share of the clusters (default [0.5, 0.5]: two classes)
neighbourhoodintegerof a cluster's cells: 4 (default) or 8

nlm.random_rectangular_cluster#

Overlapping rectangles of random values (NLMR's nlm_randomrectangularcluster): rectangles with sides from minl to maxl cells, each of a uniform value, until the map is covered.

InputTypeWhat it is
likemapa map whose grid to draw on (else rows x columns)
OutputTypeWhat it is
mapmapthe values
SettingTypeWhat it is
rowsintegerrows (default 256)
columnsintegercolumns (default 256)
resolutionnumberthe cells' side (default 1)
seedintegerthe seed of R's generator (default 1): NLMR's map for it
rescaleboolrescale the values to 0-1 (default true)
minlrequiredintegerthe shortest side, in cells
maxlrequiredintegerthe longest, at most the rows and the columns

nlm.rescale#

A map rescaled to 0-1 (NLMR's util_rescale): (x - min) / (max - min), all 0 when the minimum and maximum are all.equal.

InputTypeWhat it is
maprequiredmapthe values
OutputTypeWhat it is
mapmaprescaled