distance_clustering {VoxR} | R Documentation |
Clustering of non connected objects in a point cloud.
Description
Clustering objects with non common points: two points located within a user defined distance from each other are considered as the parts of a unique object. This function is well suited to be applied to the outputs of the substract_point_clouds function.
Clustering objects with non common points: two points located within a user defined distance from each other are considered as the parts of a unique object. This function is well suited to be applied to the outputs of the substract_point_clouds function.
Usage
distance_clustering(data, d_clust, method, C_size, message)
distance_clustering(data, d_clust, method, C_size, message)
Arguments
data |
a data.frame or data.table containing the x, y, z, ... coordinates of a point cloud or voxel cloud. |
d_clust |
numeric. The distance required to consider two points as being part of two different clusters. Default = 0.02. |
method |
character. The algorithm to use for clustering. Can be either "D_mat" or "Iter", see details. Default = "D_mat". |
C_size |
(optional) numeric. If |
message |
logical. If FALSE, messages are disabled. Default = TRUE. |
Details
If method == "D_mat"
the clustering process is based on building a matrix distance. This is time efficient but use a lot of memory.
If method == "Iter"
a slower but memory efficient iterative process is used. In some cases, D_clust can help to speed up the process.
Value
The input data with an additionnal field containing the cluster ID.
The input data with an additionnal field containing the cluster ID.
References
Lecigne, B., Delagrange, S., & Messier, C. (2018). Exploring trees in three dimensions: VoxR, a novel voxel-based R package dedicated to analysing the complex arrangement of tree crowns. Annals of botany, 121(4), 589-601.
Examples
#- import datasets
t0=data.table::fread(system.file("extdata", "Tree_t0.asc", package="VoxR"))
t1=data.table::fread(system.file("extdata", "Tree_t1.asc", package="VoxR"))
#- keep only the tree crown
t0 = t0[z>=0,]
t1 = t1[z>=0,]
#- substract t0 to t1 with the hull method
diff = VoxR::substract_point_clouds(t0 = t0,t1 = t1, method = "hull")
#- clustering the difference between t0 and t1
clust = VoxR::distance_clustering(diff,d_clust = 0.03)
#- plot the result (NOTE that colors are redundant)
rgl::open3d()
rgl::plot3d(clust,col=clust$cluster,add=TRUE)
#- import datasets
t0=data.table::fread(system.file("extdata", "Tree_t0.asc", package="VoxR"))
t1=data.table::fread(system.file("extdata", "Tree_t1.asc", package="VoxR"))
#- keep only the tree crown
t0 = t0[z>=0,]
t1 = t1[z>=0,]
#- substract t0 to t1 with the hull method
diff = VoxR::substract_point_clouds(t0 = t0,t1 = t1, method = "hull")
#- clustering the difference between t0 and t1 with the matrix distance based method
clust = VoxR::distance_clustering(diff,d_clust = 0.03)
#- plot the result (NOTE that colors are redundant)
rgl::open3d()
rgl::plot3d(clust,col=clust$cluster,add=TRUE)
#- clustering the difference between t0 and t1 with the iterative method
clust = VoxR::distance_clustering(diff,d_clust = 0.03,method = "Iter")
#- plot the result (NOTE that colors are redundant)
rgl::open3d()
rgl::plot3d(clust,col=clust$cluster,add=TRUE)
#- clustering the difference between t0 and t1 with the iterative method with maximum object size
clust = VoxR::distance_clustering(diff,d_clust = 0.03,method = "Iter",C_size = 1)
#- plot the result (NOTE that colors are redundant)
rgl::open3d()
rgl::plot3d(clust,col=clust$cluster,add=TRUE)