Introduction: measuring spatio-ecological heterogeneity

Spatio-ecological heterogeneity plays a significant role in shaping various ecosystem properties, including the distribution of species (Kumar et al. 2006; Cervellini et al. 2020), the habitat structure (Deák et al. 2021), and the variability of ecosystem elements (Turner et al. 2013). From this point of view, remote sensing has been widely acknowledged as a powerful tool to measure the spatial heterogeneity of ecosystems based on pixel variability in space and, potentially, in time (Skidmore et al. 2021; Rocchini et al. 2010).

Numerous methods for assessing spatial heterogeneity have been suggested, and they can be broadly categorized into two groups: those linked to abundance (e.g., Shannon’s H, Shannon, 1948) and those linked to dispersion (e.g., Variance). A measure coupling such information is Rao’s quadratic entropy (hereafter also referred to as Rao’s Q index, (Rao 1982)), in which both the abundance and the pairwise distance of objects is considered (see Eq. 1). The potential of such a measure has been widely acknowledged by ecologists to measure biodiversity, in particular when considering functional diversity measures based on in-situ gathered plant traits (Botta-Dukát 2005). Concerning spatio-ecological heterogeneity measurement, Rocchini et al. (2017) first proposed to extend the Rao’s Q index to a spatial (2D) dimension. In practical terms, given any kind of remote sensing data treated as a matrix, a moving window (kernel) can be passed over such a matrix and the Rao’s Q index can be calculated in a neighborhood. The founding principle in the translation from plant communities to spatio-ecological diversity is that pixels are thought of as individual units - as biological individuals in Rao (1982) - and their reflectance value is treated as species/class in Rocchini et al. 2022.

Spatial Rao’s Q has then been widely used to relate spatial heterogeneity to ecosystem properties like local (Conti et al. 2021) and global (Randin et al. 2020) biodiversity patterns, plant structural properties (Torresani et al. 2023), plant species compositional turnover (Wang et al. 2022), plant functional diversity (Hauser et al. 2021), temporal variations of dissimilarities of plant communities (Rossi et al. 2021), coastal vegetation dynamics (Malavasi et al. 2021), tropical (Pangtey et al. 2023) and alpine (Michele et al. 2018) trees diversity and marine habitat changes (Doxa et al. 2022). The question that emerges is why researchers should opt for the adoption of a complex measure that encompasses multiple dimensions and integrates both abundance and distance measurements, rather than relying on straightforward dispersion-based measures of heterogeneity, such as variance (Graham et al. 2019; Wang et al. 2022).

In this paper, we want to shed light on the spatial Rao’s Q index from different perspectives, with a focus on its statistical properties. In particular, our aim is to theoretically demonstrate the power of the Rao’s Q index in measuring heterogeneity accounting for all of its potential facets and applications, such as (i) multivariate data integration, (ii) differential weighting of pixels, and (iii) differential weighting of spectral distances, namely the distances among pixel reflectance values in the space defined by the bands of a remotely sensed image as axes. The flow of the presented formula is available in Fig. 1.

What does the Rao’s Q index actually measure?

In the realm of remote sensing applications, the process of discerning the spatial distribution of diversity within a digital image, specifically identifying areas of the image that exhibit higher diversity compared to others, commonly involves the computation of diversity indices. These indices are typically calculated within specific regions of interest or by utilizing moving windows (Fig. 2, (Rocchini et al. 2021)). Accordingly, given a moving window of any size and shape composed of N pixels, the Rao’s Q index can be defined as the expected spectral dissimilarity between two pixels drawn at random with replacement from the window:

$$\begin{aligned} Q = \displaystyle \sum _{i,j}^{N} \frac{1}{N} \times \frac{1}{N} \times d_{ij} \end{aligned}$$
(1)

where \(\frac{1}{N}\) is the probability of drawing pixel i (or j) out of N pixels and \(d_{ij}\) is the spectral dissimilarity between pixels i and j such that \(d_{ij}=d_{ji}\) (i.e., \(d_{ij}\) is symmetric) and \(d_{ii}=0\) (the spectral dissimilarity of a pixel with itself equals zero).

Therefore, according to Eq. 1, in its simplest formulation, Rao’s Q index is nothing more than the mean spectral dissimilarity among the N pixels in the moving window, including the dissimilarity of one pixel with itself. The dissimilarity \(d_{ij}\) can be computed either from a single spectral band as the difference in values between two pixels or in a multivariate spectral space by means of one of the many multivariate dissimilarity coefficients used in exploratory data analysis (see, e.g., Legendre and Legendre 2012). Hence, unlike more standard diversity indices which are calculated on a single band at a time, the Rao’s Q index can accommodate multivariate differences between digital numbers (DNs).

It is easily shown that for a fixed number of pixels N, the relationship between the Rao’s Q index and the expected spectral dissimilarity between two pixels drawn at random without replacement from the window \(Q^{'} = \displaystyle \sum _{i \ne j}^{N} \frac{1}{N} \times \frac{1}{N-1} \times d_{ij}\) (i.e., the standard mean dissimilarity among the N pixels) is equal to:

$$\begin{aligned} Q^{'} = \frac{N}{N-1} \times Q \end{aligned}$$
(2)

In the univariate case, if the dissimilarity in the reflectance values (DNs) of a single spectral band is computed as half the squared Euclidean distance \(d_{ij}=\frac{1}{2} \times (DN_i - DN_j)^2\), the Rao’s Q index is identical to variance, which is routinely used in remote sensing applications to compute the spatial complexity of digital images (Rocchini et al. 2017):

$$\begin{aligned} Q = \frac{1}{2} \displaystyle \sum _{i,j}^{N} \frac{1}{N} \times \frac{1}{N} \times (DN_i - DN_j)^2 = \frac{1}{N} \displaystyle \sum _{i}^{N} (DN_i - \overline{DN})^2 \end{aligned}$$
(3)

where \(\overline{DN}\) is the mean spectral reflectance of the N pixels: \(\overline{DN} = \frac{1}{N} \displaystyle \sum _{i}^{N} DN_i\). Accordingly, the Rao’s Q index can be interpreted as a distance-based multivariate generalization of the variance of a quantitative variable, such as the DNs of one or more spectral bands. As such, it represents the dispersion of DNs in multivariate space, which can be calculated with a wide variety of dissimilarity measures of choice. Champely and Chessel (2002) further showed that, under particular circumstances, quadratic diversity corresponds to the mean distance of the N pixels from the centroid of the DNs distribution in multivariate space.

Potential applications

Multivariate data integration

Compared to more classical univariate measures, the main advantage of the Rao’s Q index is that with quadratic entropy one can calculate landscape complexity using multiple spectral bands of a remotely sensed image simultaneously. By using appropriate dissimilarity measures, this multivariate approach can be further extended to integrate a mixture of different data sources in the index calculation, such as raw multispectral bands, categorical land use types derived from image classification or land use maps, ordinal values of landscape conservation status, surface temperatures obtained from thermal sensors, or LiDAR data on the vegetation structural complexity (Torresani et al. 2020). In addition, among the several dissimilarity coefficients that have been developed to handle mixed data sets (Gower 1971; Carranza et al. 1998; Podani 1999) some of them (see, e.g., Pavoine et al. 2009) allow the inclusion of variable weights for the various data sources such that the different variables may contribute differently to the calculation of multivariate landscape complexity (see Rocchini et al. 2017 for an example). In this way, if some variables are more important than others in determining landscape complexity and functioning, then they should be given greater relevance for the calculation of quadratic diversity (Pavoine et al. 2009).

Differential weighting of pixels

In Eq. 1, the weights \(w_i\) associated with each pixel are all equal to \(w_i=\frac{1}{N}\), which is the probability of drawing pixel i out of the N pixels in the moving window. Nonetheless, Rao’s quadratic entropy (intended as the mean dissimilarity among the N pixels) can also be calculated by weighting pixels differently in a way that depends on the specific user requirements. In this case, Eq. 1 becomes:

$$\begin{aligned} Q = \displaystyle \sum _{i,j}^{N} w_i \times w_j \times d_{ij} \end{aligned}$$
(4)

with \(0 \le w_i \le 1\) and \(\displaystyle \sum _{i}^{N} w=1\).

The weights associated with the different pixels may reflect properties as diverse as their conservation status, land use, vegetation cover, etc. Hence, according to Eq. 4, the N pixels are not all of the same importance, but some pixels are more important than others in determining landscape diversity.

In this framework, the contribution of pixel i to the overall spectral diversity of a given region/window (its spectral originality \(O_i\), namely the amount of information added to the main cloud of pixels) can be summarized as the mean dissimilarity between pixel i and a second pixel drawn at random with replacement from the window:

$$\begin{aligned} O_i = \displaystyle \sum _{j}^{N} w_j \times d_{ij} \end{aligned}$$
(5)

Accordingly, the Rao’s Q index in Eq. 4 can also be interpreted as the mean spectral originality of the N pixels in the moving window (see Ricotta et al. 2016), such that:

$$\begin{aligned} Q = \displaystyle \sum _{i}^{N} w_i \times O_i = \displaystyle \sum _{i,j}^{N} w_i \times w_j \times d_{ij} \end{aligned}$$
(6)

Differential weighting of spectral distances: a parametric version of the Rao’s Q index

As shown in Eq. 1, the Rao’s Q index basically summarizes the mean spectral dissimilarity among the N pixels in a given region/window. However, in some cases, it might be useful to confer to higher distances a higher weight enhancing the highest possible gradient of diversity.

One method for attributing a different relevance to the higher spectral dissimilarities \(d_{ij}\) compared to lower dissimilarities has been first proposed by Rocchini et al. (2021). Their proposal starts from the observation of Guiasu and Guiasu (2011) that Rao’s Q index can be described as a linear function of the combined probabilities of all pairs of pixels (see Rocchini et al. 2021):

$$\begin{aligned} Q = \displaystyle \sum _{i,j}^{N} \frac{1}{N} \times \frac{1}{N} \times d_{ij} = \displaystyle \sum _{i,j}^{N} \pi _{ij} \times d_{ij} \end{aligned}$$
(7)

where \(\pi _{ij}\) is the combined probability of selecting pixels i and j in this order (Guiasu and Guiasu 2011). Consequently, based on Eq. 7, quadratic diversity is derived as the arithmetic mean of spectral dissimilarities \(d_{ij}\) computed between all pixel pairs i and j.

In order to assign a different level of relevance to higher dissimilarities compared to lower dissimilarities, a natural way consists of substituting the arithmetic mean in Eq. 7 with a power mean or generalized mean (Hardy et al. 1952):

$$\begin{aligned} Q_{\alpha } = \Biggl (\displaystyle \sum _{i,j}^{N} \pi _{ij} \times d_{ij}^\alpha \Biggl )^\frac{1}{\alpha } \end{aligned}$$
(8)

with \(\alpha >0\).

Each generalized mean \(Q_\alpha\) always lies between the smallest and largest of the original values: min \(d_{ij} \le Q_\alpha \le\) max \(d_{ij}\) and, for increasingly high values of the parameter \(\alpha\), progressively assigns higher relevance to higher dissimilarities in the calculation of quadratic diversity.

In this view, some characteristic values of the parameter \(\alpha\) recover some more standard concepts of means. For instance, for \(\alpha\) approaching 0, quadratic diversity approaches the geometric mean \(Q_0=\root N \of {\displaystyle \prod _{ij}^{N} \times \pi _{ij} \times d_{ij}^2}\); for \(\alpha =1\), we get the standard arithmetic mean in Eq. 7; for \(\alpha =2\), we get the cubic mean \(Q_2=\sqrt{\displaystyle \sum _{i,j}^N \pi _{ij} \times d_{ij}^2}\), while for \(\alpha \rightarrow \infty\), we get \(Q_\infty \rightarrow\)max \(d_{ij}\). Hence, the generalized version of quadratic diversity embodies a continuum of potential diversity measures that differ in their sensitivity to higher and lower spectral dissimilarities.

Outlook

When using Rao’s quadratic entropy, three main important possibilities can be applied: (i) the possibility to use it in a multivariate space and generalize it, (ii) the possibility to differentially weight pixel values, and (iii) the possibility to differentially weight distances in the spectral space.

Concerning the first point, the Rao’s Q index is a multivariate notion that puts a number of traditional measures of remotely sensed landscape heterogeneity under the same umbrella. As such, it is not an alternative to more classical measures of remotely sensed landscape complexity, such as variance or the mean spectral dissimilarity among pixels. In fact, a univariate version of the Rao’s Q index, calculated on a single digital layer, should reduce to any metric based on data dispersion. On the contrary, the implicit properties of Rao’s Q index as a multivariate and potentially generalized measure of heterogeneity would enhance the capabilities of measuring landscape diversity from drone or satellite imagery (see the “Multivariate data integration" section), adding information to the simple contrast derived from univariate measures.

Furthermore, with respect to other information theory-based measures, the Rao’s Q index allows to differentially weight pixels. When using meaningful landscape variables (e.g., some land use class of interest) or known properties of spectral response in a certain band, a differential weight of pixels suspected to be related to peculiar ecological processes can enhance their strength, relying on, e.g., a spatial weighting matrix (Bauman et al. 2018). This is particularly important, especially under the perspective of information theory in which only abundance and richness are strictly considered. However, once using continuous remotely sensed imagery data, it is expected that neighboring pixels have different values from each other. In these cases, Rao’s Q, which considers distances, could weigh in a different manner the relative diversity in the used moving window. Figure 3 represents an example of a Sentinel-2 satellite image of the Sella pass in the Dolomites (46\(^\circ\)30\('\)30\(''\)N - 11\(^\circ\)46\('\)00\(''\)E, datum WGS84, Northern Alps, Italy). As an input set, we made use of NDVI (Normalized Difference Vegetation Index), a spectral index based on the high reflectance in the near infrared and the high absorption in the red wavelengths by plants representing plant biomass. In this case, a single layer was used since Shannon’s H can only be calculated on univariate variables. The Shannon index and the Rao’s Q were applied with different moving windows, i.e., windows moving throughout the whole image at a given spatial grain to make the calculation. Since all pixels have different reflectance values in the original image, the Shannon index always leads to maximum diversity over the whole image. On the contrary, Rao’s Q considers not only differences in the relative abundance but also distances among pixel values. Hence, moving windows containing different pixels with a lower spectral distance showed a lower variability while those with pixels with higher spectral distances showed high variability. Hence, in general, the final graphical perception is a wider range of colors when using Rao’s Q rather than the Shannon index. This pattern was apparent despite the spatial grain used. The complete code and data to reproduce the example is available at: https://github.com/ducciorocchini/Theoretical_Ecology_paper/.

From this point of view, a different weight to larger distances has also a well-grounded ecological meaning. In fact, larger distances account for the highest possible turnover in a species or spectral community and are therefore of valuable importance to describe the gradient of diversity (Rocchini 2007). Moreover, just adding a single category to the set of categories in the window of analysis can lead to a wide increase of diversity in case its distance from the others is higher than the (previous) mean distance (Shimatani 1999; Pavoine et al. 2009). Hence, focusing on maximum distances can help evaluating potential trends of \(\beta\)-diversity (spatial turnover) otherwise lost when only considering mean distances (Baselga 2013). Moreover, using different weights on distances can help discover all the potential facets of (Rao’s Q index) spectral diversity on the entire cloud of pixels. In other words, weighting distances can help convey information on the lower and upper boundaries of diversity. This is not only true for diversity patterns measured at the ecosystem or species levels, but more generally for any model relating species to habitats. In these cases, different distance weighting leads to different patterns in the relationship between habitat cover and species abundance which is generally multi-scalar (Aue et al. 2012).

The relationship of species with habitats that rule their life can be explicitly estimated through remote sensing (Skidmore et al. 2021); applying proper measures like the Rao’s Q index could enhance the power of remotely sensed data for species diversity estimate at different spatial scales and in a multivariate ecological space. This could be powered by linking species in the field with their spectral signatures, based on a concept known as “spectral species,” which represent the particular spectral signal of every plant species on the ground (Féret and Asner 2014; Rocchini et al. 2022). Starting from this concept, maps of alpha- or beta-diversity could be derived by the Rao’s Q index applied to hyperspectral data based on a high amount of different bands ensuring to capture of peaks related to each spectral (and ground) species.

Remote sensing data are particularly powerful in measuring diversity changes in space and time as they provide long-term images at constant intervals. That is why a plethora of studies has used them as ancillary variables for biodiversity in the field (see Gillespie et al. 2008 for a review). However, applying simplistic measures would definitively hide a wide part of the potential facets of diversity. From this point of view, the use of Rao’s Q entropy catches a wider spectrum of the diversity pattern. Moreover, from a practical point of view, this measure is now available in different open source packages concerning both species (e.g., the R packages FD, Picante, SYNCASA, Rarefy) and spectral (e.g., the R packages rasterdiv) variability (Box 1).

Criticism arises about the real match between species and spectral diversity. In fact, in some cases, spectral heterogeneity does not necessarily correspond to species diversity in the field. In other words, heterogeneity patterns derived from the spectral signal could be related to land use classes or objects that do not reflect diversity patterns, e.g., wide urban areas (Rocchini et al. 2021) or seminatural areas with plantations mixed to natural forests (Fassnacht et al. 2022). Of course, in this view, remote sensing cannot be generally seen as a surrogate for species diversity measurement in the field but rather as a preliminary exploratory for first information about the spectral signatures of plant species.

Conclusion

Any index of diversity should account for differences among categories as well as the proportions of such categories (Pavoine 2012). From this point of view, the main lesson learned is that Rao’s Q index satisfies these requirements from several points of view, guaranteeing not only to make use of relative abundances and distances but also to tune the index with a differential weighting of both categories (pixel values) and (spectral) distances.

Moreover, testing the interaction of different factors accounting for diversity is an important component of any measurement of diversity (Legendre and Anderson 1999). Using the Rao’s Q index allows for the interpretation of results on diversity based on a set of different spatial layers interacting to shape biological diversity in the field.

Finally, a generalized version of Rao’s Q index allows for the identification of interesting “regions" across the entire diversity spectrum in multivariate space, revealing hidden insights that may be lost when using point descriptors that overlook the diversity gradient (Rényi 1961, 1970; Nakamura et al. 2020). While this is a long-lasting theme in the functional diversity measurement of species communities, we present the first theoretical dissertation on the mathematical properties of the spatial version of Rao’s Q index.

Fig. 1
figure 1

Flowchart of the main formulas described in this paper describing the Rao’s Q index formula (Eq. 1) and its main properties (Eq. 2 and 3). Starting from the Rao’s Q index, pixels can be differentially weighted (Eq. 4) to give more importance to specific landscape characteristics, with the possibility of calculating the contribution of each pixel (Eq. 5) as well as the spectral originality (sensu Ricotta et al. 2016) of N pixels (Eq. 6). Furthermore, one can assign a differential weight to distances, e.g., to larger distances which account for the highest possible turnover (Eqs. 7 and 8)

Fig. 2
figure 2

Description of the moving window approach to calculate any spatial measure in a neighborhood. The first moving window (red) of 3x3 pixels is passed over the original matrix/image and used to calculate a measure, in this case the Rao’s Q index, which is attached to the central pixel in the output matrix/image. Then, it moves by one step (green and then blue, etc.), and the same approach is applied. The whole process is repeated throughout the entire original matrix/image and leads to a new output with the calculated Rao’s Q index. Any odd number of pixels can be used as moving window dimension

Fig. 3
figure 3

An example of calculation of the Shannon and the Rao’s Q indices, starting from a Sentinel-2 image of the Sella pass in the Dolomites (46\(^\circ\)30\('\)30\(''\)N - 11\(^\circ\)46\('\)00\(''\)E, datum WGS84), in Northern Alps (Italy). The achieved output shows the importance of weighting spectral distances among pixels in the calculation. While the Shannon index is only considering relative abundance, Rao’s Q is explicitly considering a matrix of spectral distances in the calculation process. Since pixel continuous values of satellite imagery are expected to be different from each other, Shannon’s H will always lead to a saturation of diversity values. This is consistent over different grains of analysis (moving windows)