Learn R Programming

spdep (version 0.1-2)

poly2nb: Construct neighbours list from polygon list

Description

The function builds a neighbours list based on regions with contiguous boundaries, that is sharing one or more boundary point. The current function is interpreted and may rund slowly for many regions or detailed boundaries.

Usage

poly2nb(pl, bb, brute.search = FALSE, row.names = NULL)

Arguments

pl
list of polygons og class polylist
bb
matrix of polygon bounding boxes - columns are LL(x), LL(y), UR(x), UR(y)
brute.search
if FALSE use bounding boxes to restrict searches to lists of regions with intersecting bounding boxes
row.names
character vector of region ids to be added to the neighbours list as attribute region.id, default seq(1, nrow(x)); if polys has a region.id attribute, it is copied to the neighbours list.

Value

  • A neighbours list with class nb

See Also

summary.nb, plotpolys

Examples

Run this code
data(columbus)
xx <- poly2nb(polys, bbs)
dxx <- diffnb(xx, col.gal.nb)
plotpolys(polys, bbs, border="grey")
plot(col.gal.nb, coords, add=TRUE)
plot(dxx, coords, add=TRUE, col="red")
title(main="Differences (red) in Columbus GAL weights (black)
and polygon generated weights")
cards <- card(xx)
maxconts <- which(cards == max(cards))
if(length(maxconts) > 1) maxconts <- maxconts[1]
fg <- rep("grey", length(polys))
fg[maxconts] <- "red"
fg[xx[[maxconts]]] <- "green"
plotpolys(polys, bbs, col=fg)
title(main="Region with largest number of contiguities")

Run the code above in your browser using DataLab