[R-sig-Geo] edit.nb problem with an island
Marc Marí Dell'Olmo
marceivissa at gmail.com
Mon May 16 19:01:44 CEST 2011
Dear all,
I have a cartography with an island, i.e. a polygon that doesn't share
border with other polygons (CODIGO=3120104012). I would like to
manually assign two areas (CODIGO=3120103024 and CODIGO=3120103014) as
a neighborhood areas of this island with the edit.nb function, and
after that to obtain the neighborhood matrix. I have followed this
syntax and I don't understand why the summary(x.nb2) still shows one
region with no link...
If it helps, you can download the map at:
http://dl.dropbox.com/u/14934021/map.zip
Thank you very much,
Marc
map<-readShapePoly("F:/map/map.shp")
map<-map[order(map$CODIGO),]
x.nb<-poly2nb(map)
summary(x.nb)
#Neighbour list object:
#Number of regions: 122
#Number of nonzero links: 724
#Percentage nonzero weights: 4.864284
#Average number of links: 5.934426
#1 region with no links:
#66
#Link number distribution:
#0 2 3 4 5 6 7 8 9 10 11 12 14
#1 1 7 19 22 31 21 12 2 2 2 1 1
#1 least connected region:
#101 with 2 links
#1 most connected region:
#29 with 14 links
nb <- x.nb
which(card(nb) == 0)
attr(nb, "region.id")[which(card(nb) == 0)]
x.nb2 <- edit.nb(x.nb,polys=map)
#> x.nb2 <- edit.nb(x.nb,polys=map)
#Identifying contiguity for deletion ...
#No contiguity between chosen points
#Add contiguity? (y/n) y
#added contiguity between point 53 and 67
#Options: quit[q] refresh[r] continue[c] c
#Identifying contiguity for deletion ...
#No contiguity between chosen points
#Add contiguity? (y/n) y
#added contiguity between point 43 and 67
#Options: quit[q] refresh[r] continue[c] q
summary(x.nb2)
#Neighbour list object:
#Number of regions: 122
#Number of nonzero links: 726
#Percentage nonzero weights: 4.877721
#Average number of links: 5.95082
#1 region with no links:
#66
#Non-symmetric neighbours list
#Link number distribution:
#0 2 3 4 5 6 7 8 9 10 11 12 14
#1 1 7 18 22 32 21 12 2 2 2 1 1
#1 least connected region:
#101 with 2 links
#1 most connected region:
#29 with 14 links
More information about the R-sig-Geo
mailing list