## 2 Materials and Methods
### UAV Data Collection and Processing
#### 2.2.2 Data Processing  
We estimated the tree's location and height based on point clouds created by the Structure from Motion (SfM) photogrammetry method. Three-dimensional point clouds derived from SfM photogrammetry produced conservative and realistic measures of tree heights [12]. Alongside with point clouds, a DSM, Digital Terrain Model (DTM), and an orthomosaic were also generated from these processes [13]. The workflow comprises of three phases, namely pre-processing, processing, and post-processing. The workflow in point clouds generation and processing is illustrated in Figure 3. Pre-processing is mainly related to data acquisition including flight route planning, GCP placement and processing of overlapped images with SfM Photogrammetry. After the data is acquired, we process the images in commercial SfM photogrammetry software Agisoft Metashape Professional 1.6.1 (Agisoft LLC, St. Petersburg, Russia). The workflow is in general as follows: (1) photo alignment, (2) photo marking, (3) dense point clouds generation, (4) exporting dense point clouds, and (5) DSM and orthomosaic generation. A detailed description of this workflow can be read in the Appendix A, Table A1. Since the UAV camera cannot penetrate the mangrove canopy, the DSM includes vegetation and any above ground covers. Therefore, on the next workflow, we processed the point clouds to estimate the DTM. Orthomosaic was created by using surface information provided by the DSM and orthoretifying of the overlapping images. The processing phase consists of nine steps, which are quality checking, clipping, indexing, tiling, sorting, noise removal, ground classification, height normalisation, and generating the Canopy Height Model (CHM). Details in this phase are described in Figure 4. We used LASTools (rapidlasso GmbH, Gilching, Germany) to clean the artefacts. The Cloth Simulation Filter (CSF) algorithm [46], which is efficient to extract the bare earth in lidR package [47], was employed for ground classification. As the first step, we assess the quality and information, e.g., number of points, projection, and point density with lasinfo module. Dense point clouds derived from SfM photogrammetry still contain noise and uncertainties [48; 49]. Therefore, to get an optimal application in the mangroves environment, a cleaning procedure should be considered. The waterbody is the main noise contributor of the SfM photogrammetry point clouds. We visually inspected the orthomosaic and draw a polygon which excludes water and selected the area of interest. The raw point clouds were then clipped based on the polygon with lasclip module. Next, we tiled and indexed the clipped point clouds into a smaller tile of 40 \(\times\) 40 m and added a buffer that was 20% of the tile size. The tiling procedure is useful to decrease the computational time by taking advantage of parallel computation. Another consideration is that, the free licensed LASTools has a point limitation about 1-15 million points [50]. Therefore, tiles should be adjusted with the allowable number of points as attached to the license. The tiled points were then sorted to rearrange the points into a space-filling curve order. Afterward, we reclassified the highest points, find the highly isolated points in the dense forest, to create a temporary ground classification. Next, we mapped all the points located 0.2 m below the temporary ground as noise. These high and low noise were removed with the lsthin and lasnoise module. The cleaned photogrammetry point clouds then were processed with the CSF algorithm in the lidR package to define the ground points. An exhaustive manual revision of the ground-no ground classification was done in the dense forest to avoid ground misclassification. The point clouds were created only from what is visible to the camera within the path not penetrating the canopies, because of that only vegetation tops/canopies were included. Therefore, careful manual revision had to be made.