## 2 Materials and Methods
### Sentinel-2 Imagery Pre-Processing  
Sentinel-2 level-2A images were the input data to our classification and consisted of twelve spectral bands with varied spatial resolutions of 10 m, 20 m and 60 m, and a revisit time of five days with the twin satellite constellation [7]. Sentinel-2 level-2A products are atmosprically corrected orthoimages and correspond to bottom-of-atmosphere reflectance [61]. The Sentinel-2 archive was accessed via the Google Earth Engine's (GEE) data catalogue and processed in GEE's cloud-computing environment [9].  
We defined 2021 as our study period. A median composite image was generated from all Sentinel-2 level-2A images captured in 2021. The median method was deemed the most appropriate because of its ability to disregard reflectance outliers and its smoother output compared with other compositing methods [62]. We considered the one-year time span as a sufficient period for capturing the representative temporal dynamics of cocoa trees and for generating a quality cloud-free composite given that our study area was susceptible to high cloud coverage.  
To remove clouds, we applied the s2 cloudless algorithm, which has been developed for Sentinel-2 imagery and detects clouds per pixel at a global scale based on machine learning [63]. Its output is a cloud probability map for a given scene and it is provided pre-computed in GEE as a separate yet compatible image collection [64]. A recently published comparison study evaluated s2 cloudless as one of the best-performing cloud detection algorithms in terms of the user's and producer's accuracy [65]. The s2 cloudless parameters are user-defined [66]. After testing different parameter values, we opted for the ones that  
\begin{table}
\begin{tabular}{c c c c c} \hline \hline \multirow{2}{*}{**Data**} & **Reference** & **Cocoa** & **Cocoa** & **Non-Cocoa** \\  & **Dataset** & **Pixels** & **Polygons** & **Pixels** \\ \hline \multirow{2}{*}{Training} & Raw & 9427 & \multirow{2}{*}{68} & 9322 \\  & Refined & 4437 & & 4392 \\ \hline \multirow{2}{*}{Validation} & Raw & 405 & \multirow{2}{*}{14} & 405 \\  & Refined & 186 & & 186 \\ \hline Test & Refined & 723 & 11 & 719 \\ \hline \hline \end{tabular}
\end{table}
Table 1: Number of cocoa pixels and number of cocoa polygons they were derived from, and number of non-cocoa pixels as split for the training, validation and test datasets before and after the cocoa refinement. For the accuracy assessment of all classification schemes, only the refined reference dataset was used. Pixel size refers to 10 \(\times\) 10 m spatial resolution.  
generated fewer cloud artefacts (Table 11). Specifically, we set the maximum cloud coverage at 100% to consider all image scenes captured in 2021 for the compositing method. This way, 0.5% of our total reference data were masked out, whereas cloud coverage percentages lower than 100% yielded a larger number of masked pixels. We followed an aggressive cloud masking to ensure the removal of thin cloud residuals. Hence, we set the cloud probability threshold at 20%, above which a pixel was identified as cloudy. The s2 cloudless algorithm also detects cloud shadows by intersecting detected clouds with low-reflectance near infrared pixels [66]. In our study, pixels with less than 0.2 near-infrared reflectance were considered cloud shadows, which were examined within a 1.5 km distance from cloud edges, and a buffer of 50 m was determined around cloud-identified objects. The cloud and cloud shadow masking was implemented on each image scene from the 2021 Sentinel-2 level-2A collection. Following that, the median compositing method was applied. The resultant 2021 median composite is illustrated in Figure 12.