Last chance! 50% off unlimited learning
Sale ends in
poly2nb(pl, row.names = NULL, snap=sqrt(.Machine$double.eps),
queen=TRUE)
polylist
, or an object of a class extending SpatialPolygons
region.id
, default seq(1, nrow(x))
; if polys
has a region.id
attribute, it is copied to the neighbours list.snap
distance apart are considered to indicate contiguitynb
summary.nb
example(columbus)
coords <- coordinates(columbus)
xx <- poly2nb(columbus)
dxx <- diffnb(xx, col.gal.nb)
plot(columbus, border="grey")
plot(col.gal.nb, coords, add=TRUE)
plot(dxx, coords, add=TRUE, col="red")
title(main=paste("Differences (red) in Columbus GAL weights (black)",
"and polygon generated queen weights", sep=""))
xxx <- poly2nb(columbus, queen=FALSE)
dxxx <- diffnb(xxx, col.gal.nb)
plot(columbus, border = "grey")
plot(col.gal.nb, coords, add = TRUE)
plot(dxxx, coords, add = TRUE, col = "red")
title(main=paste("Differences (red) in Columbus GAL weights (black)",
"and polygon generated rook weights", sep=""))
cards <- card(xx)
maxconts <- which(cards == max(cards))
if(length(maxconts) > 1) maxconts <- maxconts[1]
fg <- rep("grey", length(cards))
fg[maxconts] <- "red"
fg[xx[[maxconts]]] <- "green"
plot(columbus, col=fg)
title(main="Region with largest number of contiguities")
example(nc.sids)
xxnb <- poly2nb(nc.sids)
plot(nc.sids)
plot(xxnb, coordinates(nc.sids), add=TRUE, col="blue")
Run the code above in your browser using DataLab