Learn R Programming

spots (version 0.1.0)

HnnNeighbor: Hexagonal nearest neighbor

Description

Calculate hexagonal nearest neighbors.

Usage

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<U+2013>1081 (2001)

Examples

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

Run the code above in your browser using DataLab