Supervised Classification of Tree Species in the Forest of Dean

Author

Miguel Ibañez Alvarez

Published

March 23, 2026

1 Generating Predictor Variables from PlanetScope Imagery

1.1 Understanding the PlanetScope imagery

To train our model, we used Planet surface reflectance (SR) imagery.

Surface reflectance data measures the proportion of sunlight reflected by the Earth’s surface, after correcting for atmospheric effects such as haze or moisture. This correction is essential: it ensures that images taken on different dates can be compared reliably.

Because we analysed imagery from four different seasons — winter, spring, summer, and autumn — the model can learn how vegetation changes throughout the year. These seasonal differences help improve its ability to correctly identify tree species under varying conditions.

The Planet sensor captures information in 1 spectral bands:

  • Coastal Blue
  • Blue
  • Green I
  • Green
  • Yellow
  • Red
  • Red Edge
  • Near-Infrared (NIR)

Each band captures a different portion of the light spectrum, revealing characteristics that are invisible to the human eye.

For visual interpretation, we created RGB composites combining the Red, Near-Infrared, and Blue bands. This combination enhances vegetation contrast and makes structural differences across the Aberfoyle easier to interpret.

RGB composites (Red, NIR, Blue) showing seasonal variation.

The seasonal composites reveal clear differences in vegetation appearance throughout the year.

In winter, deciduous trees appear darker due to leaf loss, while evergreen conifers maintain consistent reflectance. During spring and summer, increased chlorophyll activity enhances contrast between species. By autumn, colour changes associated with senescence introduce additional spectral variability.

These seasonal patterns provide valuable signals for machine learning models tasked with distinguishing tree species.

1.2 Creating Vegetation Indices (Summer)

Summer imagery plays a particularly important role in this analysis. During this season, vegetation is at its peak: tree canopies are fully developed, leaves are dense, and chlorophyll activity is high. These conditions provide the strongest and most stable signals for distinguishing between species.

To enhance the predictive power of the Random Forest model, we derived 4 vegetation indices from the summer scene. Vegetation indices combine different spectral bands to highlight specific plant characteristics, such as chlorophyll content, canopy density, and overall health.

Unlike raw spectral bands, vegetation indices reduce background noise and emphasise biologically meaningful differences. This leads to more robust and reliable predictions.

Because this assessment focuses on closed forest canopies, soil exposure is minimal. Therefore, we prioritised indices that capture subtle differences in plant physiology and canopy structure rather than those primarily designed to correct for soil effects.

The following indices were selected:

  • MCARI (Modified Chlorophyll Absorption Ratio Index) Sensitive to chlorophyll concentration and canopy structure, making it useful for distinguishing species with subtle differences in greenness.

  • GNDVI (Green Normalised Difference Vegetation Index) Uses the green band and is particularly responsive to chlorophyll variations. It can differentiate species with similar biomass but different physiological conditions.

  • NDVI (Normalised Difference Vegetation Index) A widely used and reliable vegetation indicator. It serves as a strong baseline and complements the more specialised indices.

  • MSAVI2 (Modified Soil-Adjusted Vegetation Index) Although soil influence is limited in closed canopies, MSAVI2 enhances structural contrast and can highlight differences in crown density.

Together, these indices provide complementary ecological information, improving the model’s ability to discriminate between tree species.

Vegetation indices derived from the summer PlanetScope imagery.

A total of 4 vegetation indices were derived from the summer imagery.

1.3 Combining Spectral Bands and Vegetation Indices

At this stage, all spectral bands and vegetation indices were combined into a single multi-layer raster.

Each individual raster layer represents a specific environmental characteristic — either a spectral band captured by the PlanetScope sensor or a derived vegetation index. Because all layers share the same spatial extent and resolution, they can be stacked together into one coherent dataset.

This multi-layer image forms the foundation of the Random Forest model. Each pixel now contains a vector of predictor variables describing seasonal reflectance patterns and vegetation properties.

In total, the model uses 36 predictor variables.

Distribution of predictor variables by category
Category Count
Winter bands 8
Spring bands 8
Summer bands 8
Autumn bands 8
Vegetation indices 4

2 Field Data: Defining the Response Variable

The response variable in this study corresponds to tree species recorded in the Forester Sub-Compartment database. These field-based records provide the ground truth needed to train and evaluate the Random Forest model.

To ensure clear and consistent spectral signatures, pure stands were selected. This avoids mixed pixels and reduces ambiguity in the training data.

A total of 206 training polygons representing 9 species were used in this analysis.

Each polygon serves as a reference area from which spectral information is extracted and linked to its corresponding species label.

3 Random Forest Classification

3.1 Forward Feature Selection (FFS)

When building machine learning models, including too many highly correlated variables can reduce model stability and increase the risk of overfitting. In other words, the model may start learning redundant information rather than meaningful ecological patterns.

To address this, a Forward Feature Selection (FFS) procedure was applied using the ffs() function from the CAST package.

This method iteratively adds predictor variables to the model, selecting those that improve performance under cross-validation. Instead of relying on intuition alone, FFS evaluates combinations of variables and retains only those that contribute meaningful predictive power.

In this analysis, model performance improved steadily as variables were added. The Cohen’s Kappa statistic — which measures classification agreement beyond chance — increased and eventually stabilised above 0.7, indicating substantial agreement.

The optimal subset consisted of 7 predictor variables.

The first plot shows how model performance changes as additional variables are included. The second plot highlights the subset of predictors retained in the final model.

Although performance continues to improve slightly with additional variables, gains become marginal after a certain point. Selecting a reduced set of predictors helps maintain interpretability while preserving strong classification accuracy.

3.2 Tuning Spatial Cross-Validation

To evaluate model performance realistically, spatial cross-validation was applied using the blockCV package in R.

Traditional cross-validation randomly splits the data into training and validation sets. However, when working with spatial data, nearby observations often share similar environmental characteristics. This spatial autocorrelation can artificially inflate model performance if neighbouring pixels appear in both training and validation datasets.

Spatial cross-validation addresses this issue by dividing the study area into spatial blocks. In each fold, all observations from one block are withheld for validation. This ensures that the model is tested on spatially independent data.

Before defining the block size, spatial autocorrelation was estimated for each predictor raster. The block size was then determined based on the median autocorrelation range across predictors.

The analysis indicated that spatial dependency extends up to approximately 582 metres`. Therefore, the study area was divided into blocks of roughly that size, ensuring spatial independence between folds.

3.3 Running the Random Forest Model

The Random Forest classifier was trained using spatial cross-validation to ensure robust performance assessment.

A 10-fold spatial cross-validation strategy was implemented through trainControl(). In each fold, entire spatial blocks were withheld from training, preventing spatial leakage between training and validation data.

The model was trained using:

7 predictor variables

9 response classes

model_rf_SELECT2$finalModel$ntree trees

Optimisation based on the Cohen’s Kappa statistic

The final model achieved a Kappa value of 0.719, indicating substantial agreement beyond chance.

The optimal number of variables randomly sampled at each split (mtry) was 2.

Random Forest 

18736 samples
    7 predictor
    9 classes: 'Birch', 'Larch', 'Lodgepole pine', 'Norway spruce', 'Oak', 'Other broadleaves', 'Other conifers', 'Scots pine', 'Sitka spruce' 

No pre-processing
Resampling: Cross-Validated (10 fold) 
Summary of sample sizes: 16851, 16752, 17014, 17031, 16822, 17014, ... 
Resampling results across tuning parameters:

  mtry  Accuracy   Kappa    
  2     0.8153489  0.7185915
  4     0.8119932  0.7132875
  7     0.8006515  0.6989578

Kappa was used to select the optimal model using the largest value.
The final value used for the model was mtry = 2.

4 Predicted map

The final classification map illustrates the spatial distribution of tree species across the Aberfoyle.

5 Accuracy Assessment

            Birch             Larch    Lodgepole pine     Norway spruce 
         94.64706          99.20239          89.15094          61.09253 
              Oak Other broadleaves    Other conifers        Scots pine 
         99.40030          81.67203          31.02041          95.70194 
     Sitka spruce 
         97.46959 
            Birch             Larch    Lodgepole pine     Norway spruce 
         97.39709          96.78988          88.94118          81.42645 
              Oak Other broadleaves    Other conifers        Scots pine 
        100.00000          99.60784          93.82716          94.75023 
     Sitka spruce 
         93.14997 
[1] 93.91012
                   Reference
Prediction            Birch   Larch Lodgepole pine Norway spruce     Oak
  Birch              1609.0     1.0            0.0           8.0     0.0
  Larch                 6.0   995.0            0.0           0.0     0.0
  Lodgepole pine        0.0     0.0          378.0          13.0     0.0
  Norway spruce         0.0     0.0           23.0         548.0     0.0
  Oak                   4.0     0.0            0.0           0.0   663.0
  Other broadleaves    24.0    12.0            0.0           0.0     0.0
  Other conifers        0.0     0.0            0.0           1.0     0.0
  Scots pine            5.0     0.0           10.0          23.0     0.0
  Sitka spruce          4.0    20.0           14.0          80.0     0.0
  Sum                1652.0  1028.0          425.0         673.0   663.0
  PA                   97.4    96.8           88.9          81.4   100.0
                   Reference
Prediction          Other broadleaves Other conifers Scots pine Sitka spruce
  Birch                           0.0            0.0        6.0         76.0
  Larch                           0.0            0.0        0.0          2.0
  Lodgepole pine                  0.0            0.0       18.0         15.0
  Norway spruce                   0.0            1.0       75.0        250.0
  Oak                             0.0            0.0        0.0          0.0
  Other broadleaves             254.0            0.0        1.0         20.0
  Other conifers                  0.0           76.0       17.0        151.0
  Scots pine                      0.0            0.0     4097.0        146.0
  Sitka spruce                    1.0            4.0      110.0       8975.0
  Sum                           255.0           81.0     4324.0       9635.0
  PA                             99.6           93.8       94.8         93.1
                   Reference
Prediction              Sum      UA
  Birch              1700.0    94.6
  Larch              1003.0    99.2
  Lodgepole pine      424.0    89.2
  Norway spruce       897.0    61.1
  Oak                 667.0    99.4
  Other broadleaves   311.0    81.7
  Other conifers      245.0    31.0
  Scots pine         4281.0    95.7
  Sitka spruce       9208.0    97.5
  Sum               18736.0        
  PA                           93.9
Confusion Matrix with User’s and Producer’s Accuracy (%)
Birch Larch Lodgepole pine Norway spruce Oak Other broadleaves Other conifers Scots pine Sitka spruce Sum UA
Birch 1609.0 1.0 0.0 8.0 0 0.0 0.0 6.0 76.0 1700 94.6
Larch 6.0 995.0 0.0 0.0 0 0.0 0.0 0.0 2.0 1003 99.2
Lodgepole pine 0.0 0.0 378.0 13.0 0 0.0 0.0 18.0 15.0 424 89.2
Norway spruce 0.0 0.0 23.0 548.0 0 0.0 1.0 75.0 250.0 897 61.1
Oak 4.0 0.0 0.0 0.0 663 0.0 0.0 0.0 0.0 667 99.4
Other broadleaves 24.0 12.0 0.0 0.0 0 254.0 0.0 1.0 20.0 311 81.7
Other conifers 0.0 0.0 0.0 1.0 0 0.0 76.0 17.0 151.0 245 31.0
Scots pine 5.0 0.0 10.0 23.0 0 0.0 0.0 4097.0 146.0 4281 95.7
Sitka spruce 4.0 20.0 14.0 80.0 0 1.0 4.0 110.0 8975.0 9208 97.5
Sum 1652.0 1028.0 425.0 673.0 663 255.0 81.0 4324.0 9635.0 18736 NA
PA 97.4 96.8 88.9 81.4 100 99.6 93.8 94.8 93.1 NA 93.9

The confusion matrix provides a detailed breakdown of classification performance for each species.

The overall accuracy reached 93.9%, indicating substantial agreement beyond chance.

Producer’s accuracy reflects how well reference species were correctly classified, while User’s accuracy indicates the reliability of each predicted class.

Some confusion remains between spectrally similar conifer species, which is expected given overlapping canopy characteristics.