determineNeighbors: Determine the k-nearest neighbors for each spatial...

Description Usage Arguments Value Examples

View source: R/core.R

Description

determineNeighbors returns an N x k matrix of the nearest neighbors for spatial locations coords, with the ith row giving indices of the k nearest neighbors to the ith location, which are selected from among the 1,...(i-1) other spatial locations. The first row is -1's, since the first location has no neighbors. The i=2 through i=(k+1) rows each necessarily contain 1:i.

Usage

1
determineNeighbors(coords, k)

Arguments

coords

N x 2 array of N 2-dimensional (x,y) spatial coordinates.

k

Scalar; number of neighbors

Value

An N x k matrix of nearest neighbor indices

Examples

1
2
coords <- cbind(runif(100), runif(100))
determineNeighbors(coords, 20)

BayesNSGP documentation built on Jan. 9, 2022, 9:07 a.m.