dnearneigh
dnearneigh is a function in the R package spdep used to construct a neighbourhood (neighbor) structure based on pairwise distances among a set of points. It returns a neighbour list object that identifies, for each observation, which other observations lie within a specified distance band. This type of structure is commonly used to build spatial weights for analyses such as Moran’s I, spatial regression, and other methods in spatial econometrics and geography.
The function takes coordinates or a spatial object and two distance thresholds, d1 and d2. For each
The result is an object of class nb, a list where each element contains the indices of
coords <- cbind(x coordinates, y coordinates)
nb <- dnearneigh(coords, 0, 1000) # neighbors within 0 to 1000 units