Learn R Programming

spdep (version 0.1-10)

dnearneigh: Neighbourhood contiguity by distance

Description

The function identifies neighbours of region points by Euclidean distance between lower (greater than) and upper (less than or equal to) bounds.

Usage

dnearneigh(x, d1, d2, row.names = NULL)

Arguments

x
matrix of point coordinates
d1
lower distance bound
d2
upper distance bound
row.names
character vector of region ids to be added to the neighbours list as attribute region.id, default seq(1, nrow(x))

Value

  • The function returns a list of integer vectors giving the region id numbers for neighbours satisfying the distance criteria.

See Also

knearneigh

Examples

Run this code
data(columbus)
k1 <- knn2nb(knearneigh(coords))
all.linked <- max(unlist(nbdists(k1, coords)))
col.nb.0.all <- dnearneigh(coords, 0, all.linked, row.names=rownames(columbus))
summary(col.nb.0.all, coords)
plotpolys(polys, bbs, border="grey")
plot(col.nb.0.all, coords, add=TRUE)
title(main=paste("Distance based neighbours 0-",  format(all.linked),
 "distance units", sep=""))

Run the code above in your browser using DataLab