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


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.


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").


There are several ways to install landscapemetrics:


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):

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:


# landscape raster

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

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.


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.