View source: R/graph_clustering.R
graph_clustering | R Documentation |
Cluster data base on k nearest neighbor graph. Non connected components are parts of different objects.
graph_clustering(las, graph)
las |
a LAS file. NOTE: the data must be ordered similarly than when the graph was created. |
graph |
a graph produced with the |
a vector with the points cluster
# import data
file = system.file("extdata", "urban.las", package="lidUrb")
las = lidR::readLAS(file)
# remove the ground
las@data = las@data[Classification == 0]
# build the knn graph with no filter
KNN = lidUrb::knn_graph(las, k = 5L)
# clustering
las = lidUrb::graph_clustering(las = las, graph = KNN)
# add random color to clusters
las@data[,cluster_plot := sample(1:20,1),by=cluster_graph]
# plot
lidR::plot(las,color="cluster_plot")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.