[R-sig-Geo] neighbour list problem - read.gwt2nb

Carsten Kirkeby ckir at vet.dtu.dk
Fri Nov 19 20:32:16 CET 2010


Hi!

I am trying to model local moran´s I with the package spdep. But there are
some hurdles to overcome first..
The first one is to make a neighbours list (by hand, specifying neighbours
in a .txt file)

I have made a .txt file with neighbours (apparently the "old style GWT", but
that should be no problem?) 
The  neighbours list file is quoted below. There are 22 points that should
have neighbours in 8 directions (less in the edge points). According to
"Applied Spatial Data Analysis with R", a neighbour relation should only be
specified one time each (which means that when writing the neighbour
relations in a list, one will write less and less neighbours to each point).
But when I run the summary of the list, the average number of links is
2.818182. This should be around 5. Have I understood this wrong? I
appreciate any help, as I have searched for a long time without results. An
example script is written below:

Sincerely
Carsten Kirkeby

Example:

library(spdep)
test <- read.gwt2nb("neighbours.txt")
summary(test)

#coordinates for the 22 points:
coox <- c(1,2,3,4,5)
cooy <- c(3,1,2,0,3)

#and a plot for illustration:
plot(test,matrix(cbind(coox,cooy),ncol=2))
text(coox,cooy,as.character(1:5),pos=rep(3,5))


Contents of the neighbours.txt file:

22
1 20 1
1 21 1
1 13 1
1 2 1
2 20 1
2 13 1
2 12 1
2 3 1
3 13 1
3 12 1
3 5 1
3 4 1
4 12 1
4 5 1
5 12 1
5 11 1
5 6 1
6 12 1
6 11 1
6 10 1
6 7 1
7 11 1
7 10 1
7 9 1
7 8 1
8 10 1
8 9 1
9 16 1
9 15 1
9 10 1
10 16 1
10 15 1
10 14 1
10 11 1
11 15 1
11 14 1
11 13 1
11 12 1
12 14 1
12 13 1
13 14 1
13 19 1
13 20 1
14 15 1
14 18 1
14 19 1
14 20 1
15 16 1
15 17 1
15 18 1
15 19 1
16 17 1
16 18 1
17 18 1
18 19 1
18 22 1
19 20 1
19 22 1
19 21 1
20 21 1
20 22 1
21 22 1


-- 
View this message in context: http://r-sig-geo.2731867.n2.nabble.com/neighbour-list-problem-read-gwt2nb-tp5756395p5756395.html
Sent from the R-sig-geo mailing list archive at Nabble.com.



More information about the R-sig-Geo mailing list