## 2 Materials and Methods
### Workflow: Two-Stage Random Forests
In other words, the 5% of each scene (with less than 10% cloud cover) is randomly selected within each combination of elevation, aspect and slope classes, so as to be evenly represented. Elevation classes are defined by every 100 m of altitude. The surface faces (north, north-east, east, south-east, south, south-west, west, north-west, and flat) identify the aspect classes. Finally, slope classes (Table 2) are delineated by increasing degrees of steepness, based on the relationship between it and snow cover, as found by other studies [71]. Before each random process, i.e., random sampling and random forest training and classification/prediction steps, seeds were set, equal for each corresponding step of the three approaches, to ensure replicability. In A1, the RF outputs in step 2 are the daily cloud-free SCE maps at 20 m resolution (Figure 3). In A2 and A3, instead, step 2 results in daily cloud-free NDSI maps at 20 m resolution, thus, further steps are necessary to obtain the final SCE maps; i.e., retrieve a water layer to mask out water bodies and extract the snow cover from the NDSI map. \begin{table}
\begin{tabular}{c c c c c} \hline \hline
**Figure 2** & **Data** & **Approach 1** & **Approach 2** & **Approach 3** & **RF Variables** \\ \hline (a) & MOD10A1 dataset & FSC & FSC & NDSI & \\ (b) & S2 dataset & SCE & NDSI & NDSI & \\ \hline \hline \end{tabular}
\begin{tabular}{c c c c} \hline \hline
**Figure 3** & Elevation \\  & & Slope \\  & & Aspect \\  & & Aspect \\  & & Day of Year \\  & & & Latitude \\  & & Longitude \\  & & Year \\ \hline \hline \end{tabular}
\end{table} 
Table 1: Description of the different input datasets and random forests selected in the three different approaches compared in this study. Fractional Snow Cover (FSC), Snow Cover Extent (SCE), Normalized Difference Snow Index (NDSI). \begin{table}
\begin{tabular}{c c} \hline \hline
**Slope (Degrees)** & **Class** \\ \hline
0–5 & 1 \\ \hline
5–10 & 2 \\ \hline
10–15 & 3 \\ \hline
15–20 & 4 \\ \hline
20–25 & 5 \\ \hline
25–35 & 6 \\ \hline
35–45 & 7 \\ \hline \hline \end{tabular}
\end{table} 
Table 2: Classes of slope for the training data sampling. The water mask is automatically extracted from the Normalized Difference Water Index (NDWI) [72] map derived from the first near-cloud and snow-free S2 image of the ingested collection, using a fixed threshold of 0.3 (i.e., NDWI > 0.3 is considered water and < 0.3 not water). Finally, the SCE map is extracted, using a restrictive NDSI threshold (NDSI > 0.4) in the first instance to extract the snowline elevation (i.e., the lower altitudinal snow limit) and then applying a less restrictive (NDSI > 0.2) one in the second, excluding areas below this threshold and water areas. The first NDSI threshold is widely accepted in optical satellite snow detection [73; 74], while the second was established through a trial-and-error approach. The final output is, therefore, the binary snow cover map for all three approaches (Figure 4). Random forest (RF) consists of an ensemble learning method for classification and regression that operates by constructing a multitude of decision trees at training time [75]. For classification tasks, the output of the random forest is the class selected by most trees. For regression tasks, the average prediction of the individual trees is returned. In the case of regression forests, the prediction values always lie within the range of observed values. Figure 4: Example of three scenes outputs. First row: MODIS Fractional Snow Cover (FSC) data; second row: real S2 Snow Cover Extent (SCE), with gaps due to clouds and cloud shadows and No Data; third to fifth rows: output SCE maps. In the days without S2 acquisition, as in (c), the entire scene is predicted. In this study, we used the random forest models growth through the _ranger_ package [76], which has the advantage of running in parallel individual trees in C++ exploiting different cores; widely used in the processing of large data sets, such as satellite imagery [58; 77; 78].