graph_clustering: Cluster data base on k nearest neighbor graph. Non connected...

View source: R/graph_clustering.R

graph_clusteringR Documentation

Cluster data base on k nearest neighbor graph. Non connected components are parts of different objects.

Description

Cluster data base on k nearest neighbor graph. Non connected components are parts of different objects.

Usage

graph_clustering(las, graph)

Arguments

las

a LAS file. NOTE: the data must be ordered similarly than when the graph was created.

graph

a graph produced with the knn_graph or delaunay_graph functions.

Value

a vector with the points cluster

Examples


# 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")


Blecigne/lidUrb documentation built on Feb. 19, 2024, 9:12 a.m.