knn_graph | R Documentation |
Build a nearest neighbor graph and filter the edges.
knn_graph(
las,
k = 10L,
local_filter = NULL,
global_filter = NULL,
max_edge_length = NULL
)
las |
a LAS file. |
k |
integer. The number of neighbors to use to construct the graph. |
local_filter |
numeric (optional). If declared, applies a local edge filter that, allow to remove, for each node, the edges that are longer than the mean edge distance+local_filter*sd(mean(distance)). |
global_filter |
numeric between 0 and 1 (optional). If declared, applies a global
edge filter by removing all edges longer than the |
max_edge_length |
numeric (optional). If declared, removes all edges longer than max_edge_length.< |
an data.table containing the nodes ID (their position within the LAS data) and the length of the edge.
# import data
file = system.file("extdata", "tree_no_leaves.las", package="lidUrb")
las = lidR::readLAS(file)
# build the knn graph with no filter
KNN = lidUrb::knn_graph(las, k = 5L)
# plot the graph
lidUrb::plot_graph(las = las, graph = KNN)
# build the knn graph with local filter and all edges longer than 5cm removed
KNN = lidUrb::knn_graph(las, k = 5L,local_filter = 0.5,max_edge_length = 0.05)
# plot the new graph
lidUrb::plot_graph(las = las, graph = KNN)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.