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

landscapemetrics

Landscape Metrics for Categorical Map Patterns in R.
https://github.com/r-spatialecology/landscapemetrics

Category: Natural Resources
Sub Category: Soil and Land

Keywords

landscape-ecology landscape-metrics r raster spatial

Keywords from Contributors

landscape geo ecology visualisation biodiversity neutral-landscape-model route conservation trait functional-trait

Last synced: about 2 hours ago
JSON representation

Repository metadata

Landscape Metrics for Categorical Map Patterns 🗺️ in R

README.Rmd

          ---
output: 
    github_document:
      html_preview: false
---

```{r setup, include = FALSE}
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.path = "man/figures/README-",
  out.width = "100%"
)
```

# landscapemetrics 



README last updated: `r Sys.Date()`



| CI | Development | CRAN | License |
|----|-------------|------|---------|
| [![R-CMD-check](https://github.com/r-spatialecology/landscapemetrics/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/r-spatialecology/landscapemetrics/actions/workflows/R-CMD-check.yaml) | [![Lifecycle](https://img.shields.io/badge/Lifecycle-stable-brightgreen.svg)](https://lifecycle.r-lib.org/articles/stages.html) | [![CRAN status](https://www.r-pkg.org/badges/version/landscapemetrics)](https://cran.r-project.org/package=landscapemetrics) | [![License: GPL v3](https://img.shields.io/badge/License-GPLv3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0) |
| [![Codecov](https://codecov.io/gh/r-spatialecology/landscapemetrics/graph/badge.svg)](https://app.codecov.io/gh/r-spatialecology/landscapemetrics) | [![Project Status](http://www.repostatus.org/badges/latest/active.svg)](https://www.repostatus.org/) | [![CRAN downloads](https://cranlogs.r-pkg.org/badges/grand-total/landscapemetrics)](https://cran.r-project.org/package=landscapemetrics) | [![DOI](https://img.shields.io/badge/DOI-10.1111/ecog.04617-yellow.svg)](https://doi.org/10.1111/ecog.04617) |



> Starting from v2.0.0, **landscapemetrics** uses `terra` and `sf` internally. More information about the `terra` package can be found here: .

## Overview

**landscapemetrics** is a `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.* 2023), 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 **terra**, and **stars** and takes `SpatRaster` or `stars` spatial objects 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 'v0.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 (v0.0).

For more information see [Publication record](https://r-spatialecology.github.io/landscapemetrics/articles/articles/publication_record.html) vignette. The get a BibTex entry, please use `citation("landscapemetrics")`. ## Installation There are several ways to install **landscapemetrics**: ```{r, eval = FALSE, echo = TRUE} # Get the stable version from CRAN install.packages("landscapemetrics") # Alternatively, you can install the development version from Github # install.packages("remotes") remotes::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_landscape()`). All functions in **landscapemetrics** start with `lsm_` (for **l**and**s**cape **m**etrics). 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: ```{r, message = FALSE, warning = FALSE, fig.align = "center", out.width = "75%"} library(landscapemetrics) library(terra) # internal data needs to be read landscape <- terra::rast(landscapemetrics::landscape) # landscape raster plot(landscape) # calculate for example the Euclidean nearest-neighbor distance on patch level lsm_p_enn(landscape) # calculate the total area and total class edge length lsm_l_ta(landscape) lsm_c_te(landscape) ``` There is also a wrapper around every metric in the package to quickly calculate a bunch of metrics: ```{r, message = FALSE} # calculate all metrics on patch level calculate_lsm(landscape, level = "patch") ``` ### 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 `vignette("utility")`. ### 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](CONTRIBUTING.md). Maintainers and contributors must follow this repository’s [CODE OF CONDUCT](CODE_OF_CONDUCT.md). ### References McGarigal K., SA Cushman, and E Ene. 2023. FRAGSTATS v4: Spatial Pattern Analysis Program for Categorical Maps. Computer software program produced by the authors; available at the following web site: Nowosad J., TF Stepinski. 2019. Information theory as a consistent framework for quantification and classification of landscape patterns. https://doi.org/10.1007/s10980-019-00830-x

Owner metadata


GitHub Events

Total
Last Year

Committers metadata

Last synced: 5 days ago

Total Commits: 1,715
Total Committers: 15
Avg Commits per committer: 114.333
Development Distribution Score (DDS): 0.463

Commits in past year: 34
Committers in past year: 2
Avg Commits per committer in past year: 17.0
Development Distribution Score (DDS) in past year: 0.088

Name Email Commits
Maximilian Hesselbarth m****h@u****e 921
marco s****o@g****m 369
jn t****i@g****m 344
Sebastian Hanss s****n@h****o 47
GitHub Actions a****s@g****m 14
GitHub n****y@g****m 5
mhesselbarth m****h@g****n 3
DavZim d****n@h****e 2
Guillermo Ponce g****e@a****t 2
kalab-oto k****o@g****m 2
laurajanegraham l****m@g****m 2
Darío Hereñú m****a@g****m 1
Matt Strimas-Mackey m****s@g****m 1
Matthias Grenié m****e@e****r 1
jsta s****2@m****u 1

Committer domains:


Issue and Pull Request metadata

Last synced: 1 day ago

Total issues: 222
Total pull requests: 119
Average time to close issues: 4 months
Average time to close pull requests: 4 days
Total issue authors: 81
Total pull request authors: 12
Average comments per issue: 5.59
Average comments per pull request: 1.16
Merged pull request: 113
Bot issues: 0
Bot pull requests: 0

Past year issues: 11
Past year pull requests: 9
Past year average time to close issues: about 1 month
Past year average time to close pull requests: about 21 hours
Past year issue authors: 7
Past year pull request authors: 2
Past year average comments per issue: 4.27
Past year average comments per pull request: 0.0
Past year merged pull request: 9
Past year bot issues: 0
Past year bot pull requests: 0

More stats: https://issues.ecosyste.ms/repositories/lookup?url=https://github.com/r-spatialecology/landscapemetrics

Top Issue Authors

  • mhesselbarth (63)
  • Nowosad (36)
  • marcosci (21)
  • ManuelSpinola (5)
  • bitbacchus (4)
  • vjjan91 (3)
  • fabiolexcastro (3)
  • filippo-ferrario (3)
  • jamiemkass (2)
  • rsbivand (2)
  • Cumaribo (2)
  • deryagulcinubc (2)
  • vicky-c-c (2)
  • CRyan21 (2)
  • jszhao (2)

Top Pull Request Authors

  • mhesselbarth (72)
  • Nowosad (24)
  • marcosci (8)
  • bitbacchus (7)
  • gponce-ars (1)
  • gitter-badger (1)
  • mstrimas (1)
  • kalab-oto (1)
  • kant (1)
  • jsta (1)
  • DavZim (1)
  • Rekyt (1)

Top Issue Labels

  • enhancement (43)
  • question (22)
  • bug (18)
  • todo (11)
  • help wanted (11)
  • future (8)
  • v2 (3)
  • good first issue (1)

Top Pull Request Labels


Package metadata

cran.r-project.org: landscapemetrics

Landscape Metrics for Categorical Map Patterns

  • Homepage: https://r-spatialecology.github.io/landscapemetrics/
  • Documentation: http://cran.r-project.org/web/packages/landscapemetrics/landscapemetrics.pdf
  • Licenses: GPL-3
  • Latest release: 2.2.1 (published 3 months ago)
  • Last Synced: 2025-04-26T12:34:58.820Z (1 day ago)
  • Versions: 34
  • Dependent Packages: 6
  • Dependent Repositories: 12
  • Downloads: 2,659 Last month
  • Docker Downloads: 34
  • Rankings:
    • Forks count: 1.891%
    • Stargazers count: 1.981%
    • Average: 5.716%
    • Dependent packages count: 7.954%
    • Downloads: 8.346%
    • Dependent repos count: 8.409%
  • Maintainers (1)
conda-forge.org: r-landscapemetrics

  • Homepage: https://r-spatialecology.github.io/landscapemetrics/
  • Licenses: GPL-3.0-only
  • Latest release: 1.5.5 (published over 2 years ago)
  • Last Synced: 2025-04-02T02:11:06.511Z (26 days ago)
  • Versions: 21
  • Dependent Packages: 0
  • Dependent Repositories: 0
  • Rankings:
    • Stargazers count: 24.193%
    • Forks count: 27.133%
    • Dependent repos count: 34.025%
    • Average: 34.132%
    • Dependent packages count: 51.175%

Dependencies

.github/workflows/Deploy-pkgdown.yaml actions
  • JamesIves/github-pages-deploy-action 4.1.4 composite
  • actions/checkout v3 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 v3 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 v3 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 v3 composite
  • r-lib/actions/setup-r v2 composite
  • r-lib/actions/setup-r-dependencies v2 composite
.github/workflows/Write-codemeta.yaml actions
  • actions/checkout v3 composite
  • r-lib/actions/setup-r v2 composite
DESCRIPTION cran
  • R >= 3.1 depends
  • sf * enhances
  • stars * enhances
  • Rcpp * imports
  • cli * imports
  • ggplot2 * imports
  • methods * imports
  • raster * imports
  • sp * imports
  • stats * imports
  • tibble * imports
  • covr * suggests
  • dplyr * suggests
  • knitr * suggests
  • rgeos * suggests
  • rmarkdown * suggests
  • terra * suggests
  • testthat * suggests

Score: 16.13532143162339