A curated list of open technology projects to sustain a stable climate, energy supply, biodiversity and natural resources.

NLMR

R package to simulate neutral landscape models.
https://github.com/ropensci/NLMR

Category: Natural Resources
Sub Category: Soil and Land

Keywords

landscape-ecology neutral-landscape-model peer-reviewed r r-package rstats spatial

Keywords from Contributors

landscape routes ecology biodiversity traits spatial-analysis tidyverse agent-based-modeling individual-based-modelling netlogo

Last synced: about 14 hours ago
JSON representation

Repository metadata

📦 R package to simulate neutral landscape models 🏔

README.Rmd

          ---
output:
  github_document:
    html_preview: false
editor_options: 
  chunk_output_type: console
always_allow_html: yes
---

```{r, echo = FALSE}
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.path = "vignettes/README-"
)
```

 
 
[![R-CMD-check](https://github.com/ropensci/NLMR/workflows/R-CMD-check/badge.svg)](https://github.com/ropensci/NLMR/actions)
[![codecov](https://codecov.io/gh/ropensci/NLMR/branch/develop/graph/badge.svg?token=MKCm2fVrDa)](https://codecov.io/gh/ropensci/NLMR)
[![CRAN\_Status\_Badge](http://www.r-pkg.org/badges/version/NLMR)](https://cran.r-project.org/package=NLMR) 
[![lifecycle](https://img.shields.io/badge/lifecycle-maturing-blue.svg)](https://www.tidyverse.org/lifecycle/#maturing)
[![](http://cranlogs.r-pkg.org/badges/grand-total/NLMR)](http://cran.rstudio.com/web/packages/NLMR/index.html) 
[![](https://badges.ropensci.org/188_status.svg)](https://github.com/ropensci/onboarding/issues/188)
[![DOI:10.1111/2041-210X.13076](https://zenodo.org/badge/DOI/10.1111/2041-210X.13076.svg)](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.python.org/pypi/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 **raster** package and returns all simulation as ``RasterLayer`` objects, thus ensuring a direct compatibility to common GIS tasks and a flexible and simple usage.
Furthermore, it simulates NLMs within a self-contained, reproducible framework.

## Installation

NLMR is not available on CRAN at the moment (see #95). The only way to install NLMR at the moment is:

```{r, eval = FALSE}
# install.packages("remotes")
remotes::install_github("cran/RandomFieldsUtils")
remotes::install_github("cran/RandomFields")
remotes::install_github("ropensci/NLMR")
```

Windows users need to install RTools first. Rtools provides a compiler and some helpers to compile code for R in Windows. Download Rtools from here: [https://cran.r-project.org/bin/windows/Rtools/](https://cran.r-project.org/bin/windows/Rtools/) and select the appropriate Rtools version (4.0 with R 4.x.x)

Install Rtools in a directory with no fancy characters in its path, e.g. `C:\R\Rtools` is safe. To install, right click on the `Rtools40.exe` and select “Run as administrator”. During the installation make sure to select "Add Rtools to PATH". Otherwise, accept all defaults for everything else.

## Example

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

```{r eval=FALSE}
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):  

```{r warning=FALSE, message = FALSE, results='asis', echo=FALSE, cache=FALSE}
library(tibble)
library(magrittr)
library(knitr)
library(kableExtra)

function_tibble <- tibble(Function = character(), Description = character(), 	Crossreference = character(), Reference = character())

# nlm_curds
function_tibble[1,1] <- "nlm_curds"
function_tibble[1,2] <- "Simulates a randomly curdled or wheyed neutral landscape model. Random curdling recursively subdivides the landscape into blocks. At each level of the recursion, a fraction of these blocks is declared as habitat while the remaining stays matrix. When option q is set, it simulates a wheyed curdling model, where previously selected cells that were declared matrix during recursion, can now contain a proportion of habitat cells"
function_tibble[1,3] <- "Figure 1a,p"
function_tibble[1,4] <- "O’Neill, Gardner, and Turner (1992); Keitt (2000)"

# nlm_distancegradient
function_tibble[2,1] <- "nlm_distancegradient"
function_tibble[2,2] <- "Simulates a distance gradient neutral landscape model. The gradient is always measured from a rectangle that one has to specify in the function (parameter origin)"
function_tibble[2,3] <- "Figure 1b"
function_tibble[2,4] <- "Etherington, Holland, and O’Sullivan (2015)"

# nlm_edgegradient
function_tibble[3,1] <- "nlm_edgegradient"
function_tibble[3,2] <- "Simulates a linear gradient orientated neutral model. The gradient has a specified or random direction that has a central peak, which runs perpendicular to the gradient direction"
function_tibble[3,3] <- "Figure 1c"
function_tibble[3,4] <- "Travis and Dytham (2004); Schlather et al. (2015)"

# nlm_edgegradient
function_tibble[4,1] <- "nlm_fbm"
function_tibble[4,2] <- "Simulates neutral landscapes using fractional Brownian motion (fBm). fBm is an extension of Brownian motion in which the amount of spatial autocorrelation between steps is controlled by the Hurst coefficient H"
function_tibble[4,3] <- "Figure 1d"
function_tibble[4,4] <- "Schlather et al. (2015)"

# nlm_gaussianfield
function_tibble[5,1] <- "nlm_gaussianfield"
function_tibble[5,2] <- "Simulates a spatially correlated random fields (Gaussian random fields) model, where one can control the distance and magnitude of spatial autocorrelation	"
function_tibble[5,3] <- "Figure 1e"
function_tibble[5,4] <- "Schlather et al. (2015)"

# nlm_mosaicfield
function_tibble[6,1] <- "nlm_mosaicfield"
function_tibble[6,2] <- "Simulates a mosaic random field neutral landscape model. The algorithm imitates fault lines by repeatedly bisecting the landscape and lowering the values of cells in one half and increasing the values in the other half. If one sets the parameter infinite to TRUE, the algorithm approaches a fractal pattern"
function_tibble[6,3] <- "Figure 1f"
function_tibble[6,4] <- "Schlather et al. (2015)"

# nlm_neigh
function_tibble[7,1] <- "nlm_neigh"
function_tibble[7,2] <- "Simulates a neutral landscape model with land cover classes and clustering based on neighbourhood characteristics. The cluster are based on the surrounding cells. If there is a neighbouring cell of the current value/type, the target cell will more likely turned into a cell of that type/value"
function_tibble[7,3] <- "Figure 1g"
function_tibble[7,4] <- "Scherer et al. (2016)"

# nlm_percolation
function_tibble[8,1] <- "nlm_percolation"
function_tibble[8,2] <- "Simulates a binary neutral landscape model based on percolation theory. The probability for a cell to be assigned habitat is drawn from a uniform distribution"
function_tibble[8,3] <- "Figure 1h"
function_tibble[8,4] <- "Gardner et al. (1989)"

# nlm_planargradient
function_tibble[9,1] <- "nlm_planargradient"
function_tibble[9,2] <- "Simulates a planar gradient neutral landscape model. The gradient is sloping in a specified or (by default) random direction between 0 and 360 degree"
function_tibble[9,3] <- "Figure 1i"
function_tibble[9,4] <- "Palmer (1992)"

# nlm_mosaictess
function_tibble[10,1] <- "nlm_mosaictess"
function_tibble[10,2] <- "Simulates a patchy mosaic neutral landscape model based on the tessellation of a random point process. The algorithm randomly places points (parameter germs) in the landscape, which are used as the centroid points for a voronoi tessellation. A higher number of points therefore leads to a more fragmented landscape"
function_tibble[10,3] <- "Figure 1k"
function_tibble[10,4] <- "Gaucherel (2008), Method 1"

# nlm_mosaicgibbs	
function_tibble[11,1] <- "nlm_mosaicgibbs	"
function_tibble[11,2] <- "Simulates a patchy mosaic neutral landscape model based on the tessellation of an inhibition point process. This inhibition point process starts with a given number of points and uses a minimisation 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)"
function_tibble[11,3] <- "Figure 1l"
function_tibble[11,4] <- "Gaucherel (2008), Method 2"

# nlm_random
function_tibble[12,1] <- "nlm_random"
function_tibble[12,2] <- "Simulates a spatially random neutral landscape model with values drawn a uniform distribution"
function_tibble[12,3] <- "Figure 1m"
function_tibble[12,4] <- "With and Crist (1995)"
# nlm_randomcluster
function_tibble[13,1] <- "nlm_randomcluster"
function_tibble[13,2] <- "Simulates a random cluster nearest‐neighbour neutral landscape. The parameter ai controls for the number and abundance of land cover classes and p controls for proportion of elements randomly selected to form clusters"
function_tibble[13,3] <- "Figure 1n"
function_tibble[13,4] <- "Saura and Martínez-Millán (2000)"

# nlm_mpd
function_tibble[14,1] <- "nlm_mpd"
function_tibble[14,2] <- "Simulates a midpoint displacement neutral landscape model where the parameter roughness controls the level of spatial autocorrelation"
function_tibble[14,3] <- "Figure 1n"
function_tibble[14,4] <- "Peitgen and Saupe (1988)"

# nlm_randomrectangularcluster
function_tibble[15,1] <- "nlm_randomrectangularcluster"
function_tibble[15,2] <- "Simulates a random rectangular cluster neutral landscape model. The algorithm randomly distributes overlapping rectangles until the landscape is filled"
function_tibble[15,3] <- "Figure 1o"
function_tibble[15,4] <- "Gustafson and Parker (1992)"

kable(function_tibble) %>%
  kable_styling(bootstrap_options = c("striped", "hover", "condensed"))
```



## See also

**NLMR** was split during its development process - to have a minimal dependency version
for simulating neutral landscape models and an utility toolbox to facilitate workflows
with raster data.
If you are interested in merging, visualizing or further handling neutral landscape models
have a look at the [landscapetools](https://github.com/ropensci/landscapetools/) package.

## Meta

* Please [report any issues or bugs](https://github.com/ropensci/NLMR/issues/new/).
* License: GPL3
* Get citation information for `NLMR` in R doing `citation(package = 'NLMR')`
    * Additionally, we keep a [record of publications](https://ropensci.github.io/NLMR/articles/publication_record.html/) that use **NLMR**. Hence, if you used **NLMR** please [file an issue on GitHub](https://github.com/ropensci/NLMR/issues/new/) so we can add it to the list.
* We are very open to contributions - if you are interested check out our [Contributor Guidelines](CONTRIBUTING.md).
    * Please note that this project is released with a [Contributor Code of Conduct](CONDUCT.md). By participating in this project you agree to abide by its terms.

[![ropensci_footer](https://ropensci.org/public_images/github_footer.png)](http://ropensci.org)

        

Owner metadata


GitHub Events

Total
Last Year

Committers metadata

Last synced: 5 days ago

Total Commits: 444
Total Committers: 16
Avg Commits per committer: 27.75
Development Distribution Score (DDS): 0.212

Commits in past year: 1
Committers in past year: 1
Avg Commits per committer in past year: 1.0
Development Distribution Score (DDS) in past year: 0.0

Name Email Commits
marcosci s****o@g****m 350
mattfrit m****c@g****e 15
csim063 s****3@g****m 15
Sebastian Hanss s****n@h****o 14
Alex Chubaty a****y@f****a 12
mhesselbarth m****h@g****m 11
lokaler Admin U****A@u****e 6
Maëlle Salmon m****n@y****e 6
Jeroen Ooms j****s@g****m 5
Cedric_IZW c****r@g****m 3
Marco m****n@g****e 2
Sciaini, Marco m****n@b****e 1
Maximilian Hesselbarth m****h@m****l 1
rubak r****k@m****k 1
Rekyt m****e@e****r 1
GitHub Actions a****s@g****m 1

Committer domains:


Issue and Pull Request metadata

Last synced: 1 day ago

Total issues: 67
Total pull requests: 45
Average time to close issues: 2 months
Average time to close pull requests: about 1 month
Total issue authors: 25
Total pull request authors: 10
Average comments per issue: 2.19
Average comments per pull request: 0.84
Merged pull request: 43
Bot issues: 0
Bot pull requests: 0

Past year issues: 2
Past year pull requests: 2
Past year average time to close issues: N/A
Past year average time to close pull requests: about 2 months
Past year issue authors: 2
Past year pull request authors: 2
Past year average comments per issue: 3.0
Past year average comments per pull request: 1.0
Past year merged pull request: 1
Past year bot issues: 0
Past year bot pull requests: 0

More stats: https://issues.ecosyste.ms/repositories/lookup?url=https://github.com/ropensci/NLMR

Top Issue Authors

  • marcosci (27)
  • maelle (5)
  • bniebuhr (4)
  • bitbacchus (4)
  • z3tt (3)
  • mhesselbarth (3)
  • csim063 (2)
  • Nowosad (2)
  • lionel68 (1)
  • chencaf (1)
  • wegmann (1)
  • jeroen (1)
  • tdokhelar (1)
  • stefaniebutland (1)
  • JohannesOberpriller (1)

Top Pull Request Authors

  • marcosci (20)
  • mhesselbarth (10)
  • maelle (4)
  • bitbacchus (3)
  • achubaty (2)
  • mattfrit (2)
  • chrismallon (1)
  • z3tt (1)
  • rubak (1)
  • Rekyt (1)

Top Issue Labels

  • enhancement (7)
  • bug (2)

Top Pull Request Labels


Dependencies

DESCRIPTION cran
  • R >= 3.1.0 depends
  • RandomFields * imports
  • Rcpp * imports
  • checkmate * imports
  • dplyr * imports
  • fasterize * imports
  • raster * imports
  • sf * imports
  • spatstat.geom * imports
  • spatstat.random * imports
  • stats * imports
  • tibble * imports
  • ggplot2 * suggests
  • highcharter * suggests
  • knitr * suggests
  • landscapemetrics * suggests
  • landscapetools * suggests
  • magrittr * suggests
  • pals * suggests
  • plotly * suggests
  • purrr * suggests
  • rasterVis * suggests
  • rayshader * suggests
  • rgl * suggests
  • rmarkdown * suggests
  • testthat * suggests
  • viridis * suggests
.github/workflows/Deploy-pkgdown.yaml actions
  • actions/checkout v2 composite
  • r-lib/actions/setup-pandoc v2 composite
  • r-lib/actions/setup-r v2 composite
  • r-lib/actions/setup-r-dependencies v2 composite
.github/workflows/R-CMD-check.yaml actions
  • actions/checkout v2 composite
  • actions/upload-artifact main composite
  • r-lib/actions/check-r-package v2 composite
  • r-lib/actions/setup-pandoc v2 composite
  • r-lib/actions/setup-r v2 composite
  • r-lib/actions/setup-r-dependencies v2 composite
.github/workflows/Render-readme.yaml actions
  • actions/checkout v2 composite
  • r-lib/actions/setup-pandoc v2 composite
  • r-lib/actions/setup-r v2 composite
  • r-lib/actions/setup-r-dependencies v2 composite
.github/workflows/Test-coverage.yaml actions
  • actions/checkout v2 composite
  • r-lib/actions/setup-r v2 composite
  • r-lib/actions/setup-r-dependencies v2 composite
.github/workflows/Write-codemeta.yaml actions
  • actions/checkout v2 composite
  • r-lib/actions/setup-r v2 composite
  • r-lib/actions/setup-r-dependencies v2 composite

Score: 7.19142933003638