View source: R/spatial_weights.R
spatial_adjacency | R Documentation |
This function computes the spatial adjacency matrix for a given coordinate matrix using specified parameters. Adjacency is determined by distance threshold and the maximum number of neighbors.
spatial_adjacency(
coord_mat,
dthresh = sigma * 3,
nnk = 27,
weight_mode = c("binary", "heat"),
sigma = 5,
include_diagonal = TRUE,
normalized = TRUE,
stochastic = FALSE
)
coord_mat |
A numeric matrix representing the spatial coordinates |
dthresh |
Numeric, the distance threshold defining the radius of the neighborhood (default is sigma*3) |
nnk |
Integer, the maximum number of neighbors to include in each spatial neighborhood (default is 27) |
weight_mode |
Character, the mode for computing weights, either "binary" or "heat" (default is "binary") |
sigma |
Numeric, the bandwidth of the heat kernel if weight_mode == "heat" (default is 5) |
include_diagonal |
Logical, whether to assign 1 to diagonal elements (default is TRUE) |
normalized |
Logical, whether to make row elements sum to 1 (default is TRUE) |
stochastic |
Logical, whether to make column elements also sum to 1 (only relevant if normalized == TRUE) (default is FALSE) |
A sparse symmetric matrix representing the computed spatial adjacency
coord_mat = as.matrix(expand.grid(x=1:6, y=1:6))
sa <- spatial_adjacency(coord_mat)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.