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 queen weights")
xxx <- poly2nb(polys, bbs, queen=FALSE)
dxxx <- diffnb(xxx, col.gal.nb)
plotpolys(polys, bbs, border = "grey")
plot(col.gal.nb, coords, add = TRUE)
plot(dxxx, coords, add = TRUE, col = "red")
title(main="Differences (red) in Columbus GAL weights (black)
and polygon generated rook 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