bidirectionnal_double_matching.Rd
This function performs a bidirectional 3D 2-nearest-neighbors matching between two sets of trees.
It is bidirectional because it performs an inventory to measure matching and a measure to
inventory matching. It used 2-nearest-neighbors instead of 1-nearest-neighbors to give a chance to
each tree to get matched twice so each tree as a fall back matching reducing probabilities of collision
and therefore ommission and commission between from trees that would be matched to the same reference
using a 1-nn approach.
It uses a scaled 3D distance (based on X, Y, and DBH as a proxy for Z) to identify the best match
for each tree in both directions. The final match is the most consistent and closest association
between the two sets.
bidirectionnal_double_matching(treemap, dxymax = 2, dzmax = 0.05)
A `data.table` with two columns:
Index of the measured tree
Index of the matched inventory tree, or `NA` if no match was found
The algorithm works in two passes:
From measured trees to inventory: for each measured tree, it finds its two closest neighbors in the inventory using 3D Euclidean distance. The third dimension (Z) is synthesized from the DBH (diameter at breast height), scaled to be comparable with X and Y.
From inventory to measured: the same process is repeated in reverse.
For both passes, only matches within a maximum distance (`dxymax`) in the X/Y plane and a maximum DBH
difference (`dzmax`) are retained. Each inventory tree can only be assigned to one measured tree
(and vice versa), to prevent duplicates.
If a tree has two possible matches (one in each direction), the closest in full 3D distance is chosen.
In case of ambiguous matches (i.e., multiple measured trees selecting the same inventory tree), the
one with the shortest 3D distance is kept, and the others are discarded.
This approach is particularly useful when traditional 2D proximity does not yield reliable matches
due to spatial shifts and inaccuracies. The use of DBH as a proxy for vertical position improves
the separation of nearby stems.