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=""))
data(state)
us48.fipsno <- read.geoda(system.file("etc/weights/us48.txt",
package="spdep")[1])
m50.48 <- match(us48.fipsno$State.name, state.name)
xy <- as.matrix(as.data.frame(state.center))[m50.48,]
llk1 <- knn2nb(knearneigh(xy, k=1, lonlat=FALSE))
all.linked <- max(unlist(nbdists(llk1, xy, lonlat=FALSE)))
ll.nb <- dnearneigh(xy, 0, all.linked, lonlat=FALSE)
summary(ll.nb, xy, lonlat=TRUE, scale=0.5)
gck1 <- knn2nb(knearneigh(xy, k=1, lonlat=TRUE))
all.linked <- max(unlist(nbdists(gck1, xy, lonlat=TRUE)))
gc.nb <- dnearneigh(xy, 0, all.linked, lonlat=TRUE)
summary(gc.nb, xy, lonlat=TRUE, scale=0.5)
plot(ll.nb, xy)
plot(diffnb(ll.nb, gc.nb), xy, add=TRUE, col="red", lty=2)
title(main="Differences between Euclidean and Great Circle neighbours")
Run the code above in your browser using DataLab