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
ecology landscape geo biodiversity conservation neutral-landscape-model geospatial-data netlogo individual-based-modelling agent-based-modeling
Last synced: about 18 hours ago
JSON representation
Repository metadata
Landscape Metrics for Categorical Map Patterns 🗺️ in R
- Host: GitHub
- URL: https://github.com/r-spatialecology/landscapemetrics
- Owner: r-spatialecology
- License: gpl-3.0
- Created: 2018-03-01T07:55:57.000Z (almost 8 years ago)
- Default Branch: main
- Last Pushed: 2025-11-24T08:20:41.000Z (about 1 month ago)
- Last Synced: 2025-12-17T06:40:48.672Z (9 days ago)
- Topics: landscape-ecology, landscape-metrics, r, raster, spatial
- Language: R
- Homepage: https://r-spatialecology.github.io/landscapemetrics
- Size: 75.7 MB
- Stars: 252
- Watchers: 14
- Forks: 47
- Open Issues: 9
- Releases: 30
-
Metadata Files:
- Readme: README.Rmd
- Changelog: NEWS.md
- Contributing: CONTRIBUTING.md
- License: LICENSE.md
- Code of conduct: CODE_OF_CONDUCT.md
- Codemeta: codemeta.json
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 |
|----|-------------|------|---------|
| [](https://github.com/r-spatialecology/landscapemetrics/actions/workflows/R-CMD-check.yaml) | [](https://lifecycle.r-lib.org/articles/stages.html) | [](https://cran.r-project.org/package=landscapemetrics) | [](https://www.gnu.org/licenses/gpl-3.0) |
| [](https://app.codecov.io/gh/r-spatialecology/landscapemetrics) | [](https://www.repostatus.org/) | [](https://cran.r-project.org/package=landscapemetrics) | [](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
- Name: r-spatialecology
- Login: r-spatialecology
- Email:
- Kind: organization
- Description:
- Website:
- Location:
- Twitter:
- Company:
- Icon url: https://avatars.githubusercontent.com/u/42056187?v=4
- Repositories: 9
- Last ynced at: 2023-03-07T04:25:25.000Z
- Profile URL: https://github.com/r-spatialecology
GitHub Events
Total
- Create event: 4
- Release event: 1
- Issues event: 14
- Watch event: 16
- Delete event: 2
- Issue comment event: 26
- Push event: 26
- Pull request event: 6
- Fork event: 2
Last Year
- Create event: 4
- Release event: 1
- Issues event: 12
- Watch event: 14
- Delete event: 2
- Issue comment event: 22
- Push event: 24
- Pull request event: 6
- Fork event: 2
Committers metadata
Last synced: 12 days ago
Total Commits: 1,721
Total Committers: 16
Avg Commits per committer: 107.563
Development Distribution Score (DDS): 0.465
Commits in past year: 23
Committers in past year: 3
Avg Commits per committer in past year: 7.667
Development Distribution Score (DDS) in past year: 0.304
| Name | Commits | |
|---|---|---|
| Maximilian Hesselbarth | m****h@u****e | 921 |
| marco | s****o@g****m | 369 |
| jn | t****i@g****m | 347 |
| Sebastian Hanss | s****n@h****o | 47 |
| GitHub Actions | a****s@g****m | 14 |
| GitHub | n****y@g****m | 5 |
| toddellis | t****a@g****m | 3 |
| mhesselbarth | m****h@g****n | 3 |
| kalab-oto | k****o@g****m | 2 |
| Guillermo Ponce | g****e@a****t | 2 |
| DavZim | d****n@h****e | 2 |
| laurajanegraham | l****m@g****m | 2 |
| jsta | s****2@m****u | 1 |
| Matthias Grenié | m****e@e****r | 1 |
| Matt Strimas-Mackey | m****s@g****m | 1 |
| Darío Hereñú | m****a@g****m | 1 |
Committer domains:
- github.com: 2
- ens-lyon.fr: 1
- msu.edu: 1
- hotmail.de: 1
- arstucson.net: 1
- gmail.con: 1
- hanss.info: 1
- uni-goettingen.de: 1
Issue and Pull Request metadata
Last synced: 23 days ago
Total issues: 223
Total pull requests: 132
Average time to close issues: 4 months
Average time to close pull requests: 4 days
Total issue authors: 85
Total pull request authors: 13
Average comments per issue: 5.32
Average comments per pull request: 1.08
Merged pull request: 122
Bot issues: 0
Bot pull requests: 0
Past year issues: 8
Past year pull requests: 9
Past year average time to close issues: 8 days
Past year average time to close pull requests: 1 day
Past year issue authors: 7
Past year pull request authors: 3
Past year average comments per issue: 2.25
Past year average comments per pull request: 0.56
Past year merged pull request: 6
Past year bot issues: 0
Past year bot pull requests: 0
Top Issue Authors
- mhesselbarth (63)
- Nowosad (35)
- marcosci (21)
- bitbacchus (4)
- ManuelSpinola (4)
- vjjan91 (3)
- fabiolexcastro (3)
- gregforcey (2)
- frederikvand (2)
- jamiemkass (2)
- Cumaribo (2)
- rsbivand (2)
- CRyan21 (2)
- jszhao (2)
- deryagulcinubc (2)
Top Pull Request Authors
- mhesselbarth (80)
- Nowosad (27)
- marcosci (8)
- bitbacchus (7)
- toddellis (2)
- gitter-badger (1)
- kalab-oto (1)
- kant (1)
- jsta (1)
- Rekyt (1)
- gponce-ars (1)
- mstrimas (1)
- DavZim (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
- Total packages: 3
-
Total downloads:
- cran: 4,521 last-month
- Total docker downloads: 34
- Total dependent packages: 6 (may contain duplicates)
- Total dependent repositories: 12 (may contain duplicates)
- Total versions: 78
- Total maintainers: 1
proxy.golang.org: github.com/r-spatialecology/landscapemetrics
- Homepage:
- Documentation: https://pkg.go.dev/github.com/r-spatialecology/landscapemetrics#section-documentation
- Licenses: gpl-3.0
- Latest release: v2.2.1+incompatible (published 11 months ago)
- Last Synced: 2025-12-21T13:05:50.993Z (5 days ago)
- Versions: 23
- Dependent Packages: 0
- Dependent Repositories: 0
-
Rankings:
- Dependent packages count: 5.416%
- Average: 5.598%
- Dependent repos count: 5.78%
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 11 months ago)
- Last Synced: 2025-12-21T13:05:49.955Z (5 days ago)
- Versions: 34
- Dependent Packages: 6
- Dependent Repositories: 12
- Downloads: 4,521 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 about 3 years ago)
- Last Synced: 2025-12-02T11:06:03.620Z (24 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
- 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
- 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
- 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
- actions/checkout v3 composite
- r-lib/actions/setup-r v2 composite
- r-lib/actions/setup-r-dependencies v2 composite
- actions/checkout v3 composite
- r-lib/actions/setup-r v2 composite
- 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.7654711072721