The functional diversity metrics (Richness, Evenness, Divergence) can be computed directly after dimensionality reduction. Here, we assume that each selected component correspond to a trait value (each trait is scaled over the full image), and each pixel corresponds to a species/individual (no clustering is performed, so one pixel from an individual spatial unit is seen as a different species).

################################################################################
##              MAP FUNCTIONAL DIVERSITY METRICS FRic, FEve, FDiv             ##
##          (Villeger et al, 2008 https://doi.org/10.1890/07-1206.1)          ##
################################################################################
## read selected features from dimensionality reduction
Selected_Features <- read.table(Sel_PC)[[1]]
## path for selected components
map_functional_div(Original_Image_File = Input_Image_File, 
                   Functional_File = PCA_Output$PCA_Files,
                   Selected_Features = Selected_Features, 
                   Output_Dir = Output_Dir,
                   window_size = window_size, 
                   nbCPU = nbCPU, 
                   MaxRAM = MaxRAM,
                   TypePCA = TypePCA)

These diversity metrics can also be computed directly from plots defined as polygons in the extent of the rasters. This step is key for validation, and is explained in the next step.