r-spatialecology/landscapemetrics


Landscape Metrics for Categorical Map Patterns 🗺️ in R

https://r-spatialecology.github.io/landscapemetrics

License: Other

Language: R

Keywords: landscape-ecology, landscape-metrics, r, raster, spatial


Continuous Integration Development CRAN License
Travis CI lifecycle CRAN status License: GPL v3
Appveyor Project Status CRAN downloads DOI
Coverage

landscapemetrics

Overview

landscapemetrics is an R package for calculating landscape metrics for categorical landscape patterns in a tidy workflow. The package can be used as a drop-in replacement for FRAGSTATS (McGarigal et al. 2012), as it offers a reproducible workflow for landscape analysis in a single environment. It also allows for calculations of four theoretical metrics of landscape complexity: a marginal entropy, a conditional entropy, a joint entropy, and a mutual information (Nowosad and Stepinski 2019).

landscapemetrics supports raster spatial objects and takes RasterLayer, RasterStacks, RasterBricks or lists of RasterLayer as input arguments. Every function can be used in a piped workflow, as it always takes the data as the first argument and returns a tibble.

Citation

To cite landscapemetrics or acknowledge its use, please cite the following Software note, substituting the version of the application that you used for ‘ver. 0’:

Hesselbarth, M.H.K., Sciaini, M., With, K.A., Wiegand, K., Nowosad, J. 2019. landscapemetrics: an open‐source R tool to calculate landscape metrics. Ecography, 42: 1648-1657 (ver. 0).

For more information see Publication record vignette. The get a BibTex entry, please use citation("landscapemetrics").

Installation

There are several ways to install landscapemetrics:

# Get the stable version from CRAN
install.packages("landscapemetrics")

# Alternatively, you can install the development version from Github
# install.packages("devtools")
devtools::install_github("r-spatialecology/landscapemetrics")

Announcement

Due to an improved connected-component labelling algorithm (landscapemetrics v1.4 and higher), patches are labeled in a different order than before and therefore different patch IDs might be used compared to previous versions. However, results for all metrics are identical.

Using landscapemetrics

The resolution of a raster cell has to be in meters, as the package converts units internally and returns results in either meters, square meters or hectares. Before using landscapemetrics, be sure to check your raster (see check_raster()).

All functions in landscapemetrics start with lsm_ (for landscapemetrics). The second part of the name specifies the level (patch - p, class - c or landscape - l). The last part of the function name is the abbreviation of the corresponding metric (e.g. enn for the euclidean nearest-neighbor distance):

# general structure
lsm_"level"_"metric"

# Patch level
## lsm_p_"metric"
lsm_p_enn()

# Class level
## lsm_c_"metric"
lsm_c_enn()

# Landscape level
## lsm_p_"metric"
lsm_l_enn()

All functions return an identical structured tibble:

layer level class id metric value
1 patch 1 1 landscape metric x
1 class 1 NA landscape metric x
1 landscape NA NA landscape metric x

Using metric functions

Every function follows the same implementation design, so the usage is quite straightforward:

library(landscapemetrics)
library(landscapetools)

# landscape raster
show_landscape(landscape)

# calculate for example the Euclidean nearest-neighbor distance on patch level
lsm_p_enn(landscape)
#> # A tibble: 27 x 6
#>    layer level class    id metric value
#>    <int> <chr> <int> <int> <chr>  <dbl>
#>  1     1 patch     1     1 enn     7   
#>  2     1 patch     1     2 enn     4   
#>  3     1 patch     1     3 enn     2.83
#>  4     1 patch     1     4 enn     2   
#>  5     1 patch     1     5 enn     2   
#>  6     1 patch     1     6 enn     2.83
#>  7     1 patch     1     7 enn     4.12
#>  8     1 patch     1     8 enn     4.12
#>  9     1 patch     1     9 enn     4.24
#> 10     1 patch     2    10 enn     4.47
#> # ... with 17 more rows

# calculate the total area and total class edge length
lsm_l_ta(landscape)
#> # A tibble: 1 x 6
#>   layer level     class    id metric value
#>   <int> <chr>     <int> <int> <chr>  <dbl>
#> 1     1 landscape    NA    NA ta      0.09
lsm_c_te(landscape)
#> # A tibble: 3 x 6
#>   layer level class    id metric value
#>   <int> <chr> <int> <int> <chr>  <dbl>
#> 1     1 class     1    NA te       180
#> 2     1 class     2    NA te       227
#> 3     1 class     3    NA te       321

There is also a wrapper around every metric in the package to quickly calculate a bunch of metrics:

# calculate all metrics on patch level
calculate_lsm(landscape, level = "patch")
#> Warning: Please use 'check_landscape()' to ensure the input data is valid.
#> # A tibble: 324 x 6
#>    layer level class    id metric  value
#>    <int> <chr> <int> <int> <chr>   <dbl>
#>  1     1 patch     1     1 area   0.0001
#>  2     1 patch     1     2 area   0.0005
#>  3     1 patch     1     3 area   0.0148
#>  4     1 patch     1     4 area   0.0001
#>  5     1 patch     1     5 area   0.0001
#>  6     1 patch     1     6 area   0.0014
#>  7     1 patch     1     7 area   0.0003
#>  8     1 patch     1     8 area   0.0005
#>  9     1 patch     1     9 area   0.0001
#> 10     1 patch     2    10 area   0.0035
#> # ... with 314 more rows

Utility functions

landscapemetrics further provides several visualization functions, e.g. show all labeled patches or the core area of all patches. All visualization functions start with the prefix show_ (e.g. show_cores()).

Important building blocks of the package are exported to help facilitate analysis or the development of new metrics. They all start with the prefix get_. All of them are implemented with Rcpp and have either memory or performance advantages compared to raster functions.

For more details, see the utility function vignette.

Contributing

One of the major motivations behind landscapemetrics is the idea to provide an open-source code collection of landscape metrics. This includes, besides bug reports, especially the idea to include new metrics and functions. Therefore, in case you want to suggest new metrics or functions and in the best case even contribute code, we warmly welcome to do so! For more information see CONTRIBUTING.

Maintainers and contributors must follow this repository’s CODE OF CONDUCT.

References

Project Statistics

Sourcerank 8
Repository Size 49.6 MB
Stars 115
Forks 18
Watchers 13
Open issues 14
Dependencies 17
Contributors 10
Tags 13
Created
Last updated
Last pushed

Top Contributors See all

Maximilian Hesselbarth Marco Sciaini Jakub Nowosad bitbacchus GitHub Web Flow Laura Jane Graham Matt Strimas-Mackey Joseph Stachelek Matthias Grenié Darío Hereñú

Packages Referencing this Repo

landscapemetrics
Landscape Metrics for Categorical Map Patterns
Latest release 1.4.2 - Updated - 115 stars

Recent Tags See all

v1.4.2 January 20, 2020
v1.4.1 January 12, 2020
v1.3 November 07, 2019
v1.2.2 September 10, 2019
v1.2.1 August 07, 2019
v1.2 August 07, 2019
v1.1 April 25, 2019
v1.0 March 15, 2019
v0.3.1 January 24, 2019
v0.3 December 07, 2018
stable December 07, 2018
v0.2 September 26, 2018
v0.1.1 August 14, 2018

Something wrong with this page? Make a suggestion

Last synced: 2020-01-20 17:13:49 UTC

Login to resync this repository