Landscape metrics

“R as GIS” course

Jakub Nowosad, https://jakubnowosad.com/
Remote Sensing and Spatial Modelling Research Group, University of Münster

March, 2025

Hesselbarth, M.H.K., Nowosad, J., de Flamingh, A. et al. Computational Methods in Landscape Ecology. Curr Landscape Ecol Rep 10, 2 (2025). https://doi.org/10.1007/s40823-024-00104-6

Spatial patterns of categorical rasters

Discovering and describing spatial patterns is an important part of many geographical studies, and spatial patterns are linked to natural and social processes.

Evaluation of the susceptibility of forest landscapes to agricultural expansion

Bourgoin et al., 2020, 10.1016/j.jag.2019.101958

Quantification of diversity and racial segregation

Dmowska et at., 2020, j.apgeog.2020.102239

Reinterpretation of histological images as categorized rasters and their use for disease classification (e.g., liver cancer)

Kendall et al., 2020, 10.1038/s41598-020-74691-9

Quantification of categorical spatial patterns

Spatial patterns can be quantified using landscape metrics (O’Neill et al. 1988; Turner and Gardner 1991; Li and Reynolds 1993; He et al. 2000; Jaeger 2000; Kot i in. 2006; McGarigal 2014).

Software such as FRAGSTATS, GuidosToolbox, or landscapemetrics has proven useful in many scientific studies (> 12,000 citations).

There is a relationship between an area’s pattern composition and configuration and ecosystem characteristics, such as vegetation diversity, animal distributions, and water quality within this area (Hunsaker and Levine, 1995; Fahrig and Nuttle, 2005; Klingbeil and Willig, 2009; Holzschuh et al., 2010; Fahrig et al., 2011; Carrara et al., 2015; Arroyo-Rodŕıguez et al. 2016; Duflot et al., 2017, many others..)

Example data

Randomly selected 16 rasters (100x100 cells) with different proportions of forest (green) areas from Land cover data for the year 2016 of the CCI-LC project (simplified into nine categories)



Landscape metrics

Landscape metrics

General assumption is that the spatial pattern of a landscape influences the processes that occur within it

In the last 40 or so years, several hundred different landscape metrics were developed

They quantify the composition and configuration of spatial patterns of categorical rasters

Landscape metrics

Landscape metrics can be calculated for three different levels: patch, class, and landscape (here we (mostly) focus on the landscape level)

Landscape metrics

They can be divided into several groups, for example:

  1. Area and edge metrics describe the size of patches and classes and the amount of edge. These metrics mainly characterize the composition of the landscape and are able to show dominance or rareness of classes.
  2. Shape metrics describe the shape of patches, mainly by using its area and perimeter. This can be important for many research questions, because, e.g., even though, being equal in size, long and narrow patches have probably different characteristics than a squared patch of the same size.
  3. Core metrics describe the area of patches that are not an edge. These metrics can be interesting for research questions in which, e.g., only areas that are not influenced by neighboring patches of a different class are of interest.
  4. Aggregation metrics describe if patches (of the same class) are rather clumped (aggregated) or tend to be isolated. Following, these metrics describe mainly the spatial configuration of the landscape.
  5. Diversity metrics are only available on the landscape level. They describe the abundance and dominance/rareness of classes. Thereby, they show the diversity of present classes.
  6. Complexity metrics represent various aspects of the complexity of the landscape.

Landscape metrics

  • SHDI - Shannon’s diversity index - takes both the number of classes and the abundance of each class into account; larger values indicate higher diversity (diversity metric)
  • AI - Aggregation index - from 0 for maximally disaggregated to 100 for maximally aggregated classes (aggregation metric)

SHDI:


AI:

Landscape metrics

Important considerations:

  • Scale: the size of the area over which the metrics are calculated
  • Extent: the borders of the study area
  • Spatial resolution: the size of the raster cells
  • Categorization: the categories used in the analysis
  • Redundancy: many metrics are highly correlated

Helpful resources:

{landscapemetrics}

library(landscapemetrics)
list_lsm()
       metric                                  name                 type
1        area                            patch area area and edge metric
2         cai                       core area index     core area metric
3      circle         related circumscribing circle         shape metric
4      contig                      contiguity index         shape metric
5        core                             core area     core area metric
6         enn   euclidean nearest neighbor distance   aggregation metric
7        frac               fractal dimension index         shape metric
8      gyrate                    radius of gyration area and edge metric
9       ncore                  number of core areas     core area metric
10       para                  perimeter-area ratio         shape metric
11      perim                       patch perimeter area and edge metric
12      shape                           shape index         shape metric
13         ai                     aggregation index   aggregation metric
14    area_cv                            patch area area and edge metric
15    area_mn                            patch area area and edge metric
16    area_sd                            patch area area and edge metric
17         ca                    total (class) area area and edge metric
18     cai_cv                       core area index     core area metric
19     cai_mn                       core area index     core area metric
20     cai_sd                       core area index     core area metric
21  circle_cv         related circumscribing circle         shape metric
22  circle_mn         related circumscribing circle         shape metric
23  circle_sd         related circumscribing circle         shape metric
24     clumpy                      clumpiness index   aggregation metric
25   cohesion                  patch cohesion index   aggregation metric
26  contig_cv                      contiguity index         shape metric
27  contig_mn                      contiguity index         shape metric
28  contig_sd                      contiguity index         shape metric
29    core_cv                             core area     core area metric
30    core_mn                             core area     core area metric
31    core_sd                             core area     core area metric
32     cpland     core area percentage of landscape     core area metric
33       dcad            disjunct core area density     core area metric
34   dcore_cv                    disjunct core area     core area metric
35   dcore_mn                    disjunct core area     core area metric
36   dcore_sd                    disjunct core area     core area metric
37   division                        division index   aggregation metric
38         ed                          edge density area and edge metric
39     enn_cv   euclidean nearest neighbor distance   aggregation metric
40     enn_mn   euclidean nearest neighbor distance   aggregation metric
41     enn_sd   euclidean nearest neighbor distance   aggregation metric
42    frac_cv               fractal dimension index         shape metric
43    frac_mn               fractal dimension index         shape metric
44    frac_sd               fractal dimension index         shape metric
45  gyrate_cv                    radius of gyration area and edge metric
46  gyrate_mn                    radius of gyration area and edge metric
47  gyrate_sd                    radius of gyration area and edge metric
48        iji interspersion and juxtaposition index   aggregation metric
49        lpi                   largest patch index area and edge metric
50        lsi                 landscape shape index   aggregation metric
51       mesh                   effective mesh size   aggregation metric
52       ndca         number of disjunct core areas     core area metric
53       nlsi      normalized landscape shape index   aggregation metric
54         np                     number of patches   aggregation metric
55     pafrac      perimeter-area fractal dimension         shape metric
56    para_cv                  perimeter-area ratio         shape metric
57    para_mn                  perimeter-area ratio         shape metric
58    para_sd                  perimeter-area ratio         shape metric
59         pd                         patch density   aggregation metric
60      pladj        percentage of like adjacencies   aggregation metric
61      pland               percentage of landscape area and edge metric
62   shape_cv                           shape index         shape metric
63   shape_mn                           shape index         shape metric
64   shape_sd                           shape index         shape metric
65      split                       splitting index   aggregation metric
66        tca                       total core area     core area metric
67         te                            total edge area and edge metric
68         ai                     aggregation index   aggregation metric
69    area_cv                            patch area area and edge metric
70    area_mn                            patch area area and edge metric
71    area_sd                            patch area area and edge metric
72     cai_cv                       core area index     core area metric
73     cai_mn                       core area index     core area metric
74     cai_sd                       core area index     core area metric
75  circle_cv         related circumscribing circle         shape metric
76  circle_mn         related circumscribing circle         shape metric
77  circle_sd         related circumscribing circle         shape metric
78   cohesion                  patch cohesion index   aggregation metric
79    condent                   conditional entropy    complexity metric
80     contag                           connectance   aggregation metric
81  contig_cv                      contiguity index         shape metric
82  contig_mn                      contiguity index         shape metric
83  contig_sd                      contiguity index         shape metric
84    core_cv                             core area     core area metric
85    core_mn                             core area     core area metric
86    core_sd                             core area     core area metric
87       dcad            disjunct core area density     core area metric
88   dcore_cv                    disjunct core area     core area metric
89   dcore_mn                    disjunct core area     core area metric
90   dcore_sd                    disjunct core area     core area metric
91   division                        division index   aggregation metric
92         ed                          edge density area and edge metric
93     enn_cv   euclidean nearest neighbor distance   aggregation metric
94     enn_mn   euclidean nearest neighbor distance   aggregation metric
95     enn_sd   euclidean nearest neighbor distance   aggregation metric
96        ent                       shannon entropy    complexity metric
97    frac_cv               fractal dimension index         shape metric
98    frac_mn               fractal dimension index         shape metric
99    frac_sd               fractal dimension index         shape metric
100 gyrate_cv                    radius of gyration area and edge metric
101 gyrate_mn                    radius of gyration area and edge metric
102 gyrate_sd                    radius of gyration area and edge metric
103       iji interspersion and juxtaposition index   aggregation metric
104   joinent                         joint entropy    complexity metric
105       lpi                   largest patch index area and edge metric
106       lsi                 landscape shape index   aggregation metric
107      mesh                   effective mesh size   aggregation metric
108     msidi    modified simpson's diversity index     diversity metric
109     msiei     modified simpson's evenness index     diversity metric
110    mutinf                    mutual information    complexity metric
111      ndca         number of disjunct core areas     core area metric
112        np                     number of patches   aggregation metric
113    pafrac      perimeter-area fractal dimension         shape metric
114   para_cv                  perimeter-area ratio         shape metric
115   para_mn                  perimeter-area ratio         shape metric
116   para_sd                  perimeter-area ratio         shape metric
117        pd                         patch density   aggregation metric
118     pladj        percentage of like adjacencies   aggregation metric
119        pr                        patch richness     diversity metric
120       prd                patch richness density     diversity metric
121 relmutinf           relative mutual information    complexity metric
122       rpr               relative patch richness     diversity metric
123  shape_cv                           shape index         shape metric
124  shape_mn                           shape index         shape metric
125  shape_sd                           shape index         shape metric
126      shdi             shannon's diversity index     diversity metric
127      shei              shannon's evenness index     diversity metric
128      sidi             simpson's diversity index     diversity metric
129      siei              simspon's evenness index     diversity metric
130     split                       splitting index   aggregation metric
131        ta                            total area area and edge metric
132       tca                       total core area     core area metric
133        te                            total edge area and edge metric
        level   function_name
1       patch      lsm_p_area
2       patch       lsm_p_cai
3       patch    lsm_p_circle
4       patch    lsm_p_contig
5       patch      lsm_p_core
6       patch       lsm_p_enn
7       patch      lsm_p_frac
8       patch    lsm_p_gyrate
9       patch     lsm_p_ncore
10      patch      lsm_p_para
11      patch     lsm_p_perim
12      patch     lsm_p_shape
13      class        lsm_c_ai
14      class   lsm_c_area_cv
15      class   lsm_c_area_mn
16      class   lsm_c_area_sd
17      class        lsm_c_ca
18      class    lsm_c_cai_cv
19      class    lsm_c_cai_mn
20      class    lsm_c_cai_sd
21      class lsm_c_circle_cv
22      class lsm_c_circle_mn
23      class lsm_c_circle_sd
24      class    lsm_c_clumpy
25      class  lsm_c_cohesion
26      class lsm_c_contig_cv
27      class lsm_c_contig_mn
28      class lsm_c_contig_sd
29      class   lsm_c_core_cv
30      class   lsm_c_core_mn
31      class   lsm_c_core_sd
32      class    lsm_c_cpland
33      class      lsm_c_dcad
34      class  lsm_c_dcore_cv
35      class  lsm_c_dcore_mn
36      class  lsm_c_dcore_sd
37      class  lsm_c_division
38      class        lsm_c_ed
39      class    lsm_c_enn_cv
40      class    lsm_c_enn_mn
41      class    lsm_c_enn_sd
42      class   lsm_c_frac_cv
43      class   lsm_c_frac_mn
44      class   lsm_c_frac_sd
45      class lsm_c_gyrate_cv
46      class lsm_c_gyrate_mn
47      class lsm_c_gyrate_sd
48      class       lsm_c_iji
49      class       lsm_c_lpi
50      class       lsm_c_lsi
51      class      lsm_c_mesh
52      class      lsm_c_ndca
53      class      lsm_c_nlsi
54      class        lsm_c_np
55      class    lsm_c_pafrac
56      class   lsm_c_para_cv
57      class   lsm_c_para_mn
58      class   lsm_c_para_sd
59      class        lsm_c_pd
60      class     lsm_c_pladj
61      class     lsm_c_pland
62      class  lsm_c_shape_cv
63      class  lsm_c_shape_mn
64      class  lsm_c_shape_sd
65      class     lsm_c_split
66      class       lsm_c_tca
67      class        lsm_c_te
68  landscape        lsm_l_ai
69  landscape   lsm_l_area_cv
70  landscape   lsm_l_area_mn
71  landscape   lsm_l_area_sd
72  landscape    lsm_l_cai_cv
73  landscape    lsm_l_cai_mn
74  landscape    lsm_l_cai_sd
75  landscape lsm_l_circle_cv
76  landscape lsm_l_circle_mn
77  landscape lsm_l_circle_sd
78  landscape  lsm_l_cohesion
79  landscape   lsm_l_condent
80  landscape    lsm_l_contag
81  landscape lsm_l_contig_cv
82  landscape lsm_l_contig_mn
83  landscape lsm_l_contig_sd
84  landscape   lsm_l_core_cv
85  landscape   lsm_l_core_mn
86  landscape   lsm_l_core_sd
87  landscape      lsm_l_dcad
88  landscape  lsm_l_dcore_cv
89  landscape  lsm_l_dcore_mn
90  landscape  lsm_l_dcore_sd
91  landscape  lsm_l_division
92  landscape        lsm_l_ed
93  landscape    lsm_l_enn_cv
94  landscape    lsm_l_enn_mn
95  landscape    lsm_l_enn_sd
96  landscape       lsm_l_ent
97  landscape   lsm_l_frac_cv
98  landscape   lsm_l_frac_mn
99  landscape   lsm_l_frac_sd
100 landscape lsm_l_gyrate_cv
101 landscape lsm_l_gyrate_mn
102 landscape lsm_l_gyrate_sd
103 landscape       lsm_l_iji
104 landscape   lsm_l_joinent
105 landscape       lsm_l_lpi
106 landscape       lsm_l_lsi
107 landscape      lsm_l_mesh
108 landscape     lsm_l_msidi
109 landscape     lsm_l_msiei
110 landscape    lsm_l_mutinf
111 landscape      lsm_l_ndca
112 landscape        lsm_l_np
113 landscape    lsm_l_pafrac
114 landscape   lsm_l_para_cv
115 landscape   lsm_l_para_mn
116 landscape   lsm_l_para_sd
117 landscape        lsm_l_pd
118 landscape     lsm_l_pladj
119 landscape        lsm_l_pr
120 landscape       lsm_l_prd
121 landscape lsm_l_relmutinf
122 landscape       lsm_l_rpr
123 landscape  lsm_l_shape_cv
124 landscape  lsm_l_shape_mn
125 landscape  lsm_l_shape_sd
126 landscape      lsm_l_shdi
127 landscape      lsm_l_shei
128 landscape      lsm_l_sidi
129 landscape      lsm_l_siei
130 landscape     lsm_l_split
131 landscape        lsm_l_ta
132 landscape       lsm_l_tca
133 landscape        lsm_l_te

{landscapemetrics}

library(terra)
r9 = rast("data/r9.tif")
r1 = rast("data/r1.tif")
plot(r1); plot(r9)

{landscapemetrics}: patch-level

lsm_p_perim(r9)
# A tibble: 305 × 6
   layer level class    id metric  value
   <int> <chr> <int> <int> <chr>   <dbl>
 1     1 patch     1     1 perim    1200
 2     1 patch     1     2 perim    1200
 3     1 patch     1     3 perim    1800
 4     1 patch     1     4 perim    1800
 5     1 patch     1     5 perim  255000
 6     1 patch     1     6 perim    1800
 7     1 patch     1     7 perim    1800
 8     1 patch     1     8 perim    2400
 9     1 patch     1     9 perim    6600
10     1 patch     1    10 perim    6000
# ℹ 295 more rows

{landscapemetrics}: class-level

lsm_c_ai(r9)
# A tibble: 7 × 6
  layer level class    id metric value
  <int> <chr> <int> <int> <chr>  <dbl>
1     1 class     1    NA ai      75.9
2     1 class     2    NA ai      90.4
3     1 class     3    NA ai      60.9
4     1 class     5    NA ai      46.1
5     1 class     7    NA ai      75  
6     1 class     8    NA ai       0  
7     1 class     9    NA ai      80.2

{landscapemetrics}: landscape-level

lsm_l_shdi(r9)
# A tibble: 1 × 6
  layer level     class    id metric value
  <int> <chr>     <int> <int> <chr>  <dbl>
1     1 landscape    NA    NA shdi    1.06
lsm_l_ai(r9)
# A tibble: 1 × 6
  layer level     class    id metric value
  <int> <chr>     <int> <int> <chr>  <dbl>
1     1 landscape    NA    NA ai      82.1

{landscapemetrics}: many metrics calculations

calculate_lsm(r9, what = c("lsm_l_shdi", "lsm_l_ai"))
# A tibble: 2 × 6
  layer level     class    id metric value
  <int> <chr>     <int> <int> <chr>  <dbl>
1     1 landscape    NA    NA ai     82.1 
2     1 landscape    NA    NA shdi    1.06
two_r = list(r1, r9)
calculate_lsm(two_r, what = c("lsm_l_shdi", "lsm_l_ai"))
# A tibble: 4 × 6
  layer level     class    id metric   value
  <int> <chr>     <int> <int> <chr>    <dbl>
1     1 landscape    NA    NA ai     98.7   
2     1 landscape    NA    NA shdi    0.0811
3     2 landscape    NA    NA ai     82.1   
4     2 landscape    NA    NA shdi    1.06  

{landscapemetrics}: moving window calculations

mat_window = matrix(1, nrow = 11, ncol = 11)
w_result = window_lsm(r9, window = mat_window, what = "lsm_l_ai")
plot(r9); plot(w_result$layer_1$lsm_l_ai)

{landscapemetrics}: other features

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

# A tibble: 133 × 5
   metric name                                type           level function_name
   <chr>  <chr>                               <chr>          <chr> <chr>        
 1 area   patch area                          area and edge… patch lsm_p_area   
 2 cai    core area index                     core area met… patch lsm_p_cai    
 3 circle related circumscribing circle       shape metric   patch lsm_p_circle 
 4 contig contiguity index                    shape metric   patch lsm_p_contig 
 5 core   core area                           core area met… patch lsm_p_core   
 6 enn    euclidean nearest neighbor distance aggregation m… patch lsm_p_enn    
 7 frac   fractal dimension index             shape metric   patch lsm_p_frac   
 8 gyrate radius of gyration                  area and edge… patch lsm_p_gyrate 
 9 ncore  number of core areas                core area met… patch lsm_p_ncore  
10 para   perimeter-area ratio                shape metric   patch lsm_p_para   
# ℹ 123 more rows
  • Sampling around points of interest
  • Calculating landscape metrics for irregular areas
  • Calculating landscape metrics across scales
  • Visualizations
  • More…

Exercises

The aim of this exercise is to reproduce some of the results from Ma et al., 2023, Global forest fragmentation change from 2000 to 2020, https://doi.org/10.1038/s41467-023-39221-x. However, this time, we focus on an area of 100 km around Muenster only.

  1. Read the landcover data for years 2000 and 2020 for a part of Germany from files "data/lc_2000.tif" and "data/lc_2020.tif". Visualize both datasets.
  2. Read the point representing Muenster from the "data/muenster.gpkg" file into R. Visualize it.
  3. Reproject both raster datasets to the ETRS89 LAEA (EPSG:3035) CRS with a resolution of 20 meters (hint: try the res argument of the project() function).
  4. Create a buffer of 9km around the point representing Muenster and mask the values in the rasters outside that buffer. Remember about reprojecting your data first.
  5. Reclassify both rasters into 0/1 objects, where 1 represents forests and 0 other areas using terra::classify(). In the original raster datasets, tree cover is represented by values from 25 to 48.
  6. Calculate three landscape metrics mentioned in the paper: edge density (ED), patch density (PD), and mean patch area. Interpret the results.
  7. Calculate the total area of forests in 2000 and 2020. Interpret the results.