Learn R Programming

lidR (version 4.2.1)

knn_distance: Computes the Distance to k-Nearest Neighbors

Description

Computes the average distance between each point and its k-nearest neighbors in a point cloud. The results are stored in a new attribute.

Usage

knn_distance(las, k = 10, name = "distance")

Value

A LAS object with an additional attribute named as specified by `name`.

Arguments

las

A LAS object representing the point cloud data.

k

The number of nearest neighbors.

name

A string specifying the name of the new attribute used to store the computed distances.

Examples

Run this code
LASfile <- system.file("extdata", "MixedConifer.laz", package="lidR")
las <- readLAS(LASfile, select = "xyz", filter = "-inside 481250 3812980 481300 3813030")
las = knn_distance(las)
#plot(las, color = "distance", breaks = "quantile", legend = TRUE)

Run the code above in your browser using DataLab