Calculate hexagonal nearest neighbors.

HnnNeighbor(dist.hnn, k, include.self = TRUE)

Arguments

dist.hnn

A hexagonal nearest neighbor distance matrix.

k

Number of neighbors.

include.self

Whether to include self as 1st neighbor, default is TRUE.

Value

A list containing the following:

  • knn.idx, an n x k matrix for the nearest neighbor indice.

  • knn.dist, an n x k matrix for the nearest neighbor hexagonal distances.

  • dist.mat, a connectivity-based distance matrix.

References

Middleton, L. & Sivaswamy, J. Edge detection in a hexagonal-image processing framework. Image Vis. Comput. 19, 1071–1081 (2001)

Examples

{
data.use <- quakes[1:100,]
dist.use <- as.matrix(dist(data.use[,1:2]))
res <- HnnNeighbor(dist.use, k = 10)
}