View source: R/highly_connected_graph.R
highly_connected_graph | R Documentation |
Transform a graph into a highly connected graph, i.e. a graph with nearly all points belonging to a cluster that have a minimum Z value lower than a given threshold
highly_connected_graph(las, graph, min_Z_th = 1, max_edge_length = 0.5)
las |
a LAS file. |
graph |
a graph as created by the |
min_Z_th |
numeric. The value of Z to decide if a cluster is valid or not. |
max_edge_length |
numeric. The maximum edge length that can be added to the graph. |
a highly connected grapg
# import data
file = system.file("extdata", "four_trees.las", package="lidUrb")
las = lidR::readLAS(file,select = "xyz")
# reduce point density to 0.1 instead of voxelisation as in Wang et al.
las = lidUrb::reduce_point_density(las,0.1)
# build a knn graph
KNN = lidUrb::knn_graph(las,local_filter = 0.5)
# graph clustering without highly connected graph
las = lidUrb::graph_clustering(las,KNN)
# random colors to plot not highly connected clusters
las@data[,plot_not_high := sample(1:10,1),by = cluster_graph]
# transform graph into a highly connected graph
KNN = lidUrb::highly_connected_graph(las=las,graph = KNN)
# graph clustering based on the highly connected graph
las = lidUrb::graph_clustering(las,KNN)
las@data[,plot_high := sample(1:10,1),by = cluster_graph]
# plot the result
lidR::plot(las,color="plot_not_high")
lidR::plot(las,color="plot_high")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.