a problem with creating a neighbours list
On Tue, 26 May 2015, stevenhuyi wrote:
Hi everyone, I have a simple problem, which I know will have a simple solution, but I just can't tackle it. I have a shapefile with regions, including an attribute containing a regional id. I used the following R script to create a neighbours list:
Please always state which package functions come from, here maptools:
anhui <- readShapePoly("endemic.shp")
and here spdep:
zzz<- poly2nb(anhui,row.names=anhui$COUNTY_ID)
nb2INLA("anhui.graph", zzz)
Anhui.adj <- paste(getwd(),"/Anhui.graph",sep="")
This is what spdep::nb2INLA() provides - why would you need your COUNTY_ID character value? In INLA, you usually would set idx to 1:n, not character ID values, I think? Roger
However, the Anhui.adj file is just as follows 31 1 5 3 4 5 6 7 2 2 3 7 3 3 1 2 7 4 2 1 5 ... the id number is not the original id number in my shapefile (which are actually 1289, 1290,...). Is there a way to get a neighbours list that is created using the original id number? Thanks for your help. Yi -- View this message in context: http://r-sig-geo.2731867.n2.nabble.com/a-problem-with-creating-a-neighbours-list-tp7588325.html Sent from the R-sig-geo mailing list archive at Nabble.com.
_______________________________________________ R-sig-Geo mailing list R-sig-Geo at r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-geo
Roger Bivand Department of Economics, Norwegian School of Economics, Helleveien 30, N-5045 Bergen, Norway. voice: +47 55 95 93 55; fax +47 55 95 91 00 e-mail: Roger.Bivand at nhh.no