Iteratively merges temporally adjacent putative clusters that overlap spatially.
This operates on the .putative_cluster column created by slice_ctdf() and updates it in-place.
Arguments
- ctdf
A
ctdfobject. Must contain.putative_cluster(typically produced byslice_ctdf()).- time_contiguity
Logical; if
TRUE, enforce temporal contiguity within clusters by filling internal gaps as described above. Default isTRUE.
Details
For each adjacent pair, the locations in each cluster are combined separately
and their convex hulls are tested for intersection. If the convex hulls do not
intersect, a k-nearest-neighbour (kNN) mixing test is used as a secondary
criterion. The kNN test pools the two clusters' locations, uses
floor(sqrt(n)) neighbours and compares the observed fraction of neighbours
assigned to the other cluster with the expected mixing fraction under random
labels. The pair is considered overlapping when the observed mixing is at
least 60% of that expectation.
If time_contiguity = TRUE, missing .putative_cluster values between identical
forward- and backward-filled labels are filled, so each cluster becomes
temporally contiguous (short spatial outliers inside a cluster are absorbed).
