View source: R/v03_NNGP_neighbors.R
| displayNeighbors | R Documentation |
Visualizes the neighbor set for a given location based on an ordered Nearest-Neighbor Gaussian Process (NNGP) constructed using Vecchia's approximation.
displayNeighbors(ind, coords.sorted, neighbor_idx, proj)
ind |
Integer index of the focal location (in the sorted order). |
coords.sorted |
Numeric matrix ( |
neighbor_idx |
Integer matrix ( |
proj |
Coordinate reference system (CRS) used for plotting. Can be an EPSG code
or a CRS object compatible with |
The function assumes that coordinates and neighbor indices are based on an ordered representation of the data (e.g., sorted by x-coordinate or another ordering used in Vecchia's approximation).
The neighbor set for location i consists of previously ordered locations,
as defined by the NNGP construction.
A ggplot2 object showing:
All spatial locations (black markers)
The focal location (red point)
Its neighbors (blue points)
A vertical reference line at the focal location's x-coordinate
Fabian Ketwaroo
computeNeighbors
coords <- matrix(runif(40), ncol = 2)
res <- computeNeighbors(coords, k = 5, proj = 4326)
p <- displayNeighbors(
ind = 10,
coords.sorted = res$coords_sorted,
neighbor_idx = res$neighbor_idx,
proj = 4326
)
print(p)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.