An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-sig-geo/attachments/20090527/59145c7c/attachment.pl>
nb object for spatial weigths
2 messages · anna freni sterrantino, Roger Bivand
On Wed, 27 May 2009, anna freni sterrantino wrote:
Hi everyone, I'm a total newbie in geo, so sorry if my question is basic. Following chp 9 and chp 10 from "Applied Spatial Data Analysis with R", I 've got confused on how to get from coordinates to a nb-object, to get to spatial weights need for modeling. Seems that the example at pag.245 : coords<- coordinates(Syracuse) IDs <- row.names(as(Syracuse, "data.frame")) library(tripack) Sy4_nb<- tri2nb(coords, row.names=IDs) Sy5_nb<- graph2nb(soi.graph(Sy4_nb, coords), row.names=IDs) Sy6_nb<- graph2nb(gabrielneigh(coords), row.names=IDs) Sy7_nb<- graph2nb(relativeneigh(coords), row.names=IDs) in not working anymore, due to the fact that tri2nd has been deprecated; so I tried instead
I don't think that anything has happened to tri2nb(), which lives in spdep. If spdep wasn't loaded, you wouldn't find tri2nb() - was that the problem? The book code is run nightly on current R and the contributed packages, so I'd have expected to see any deviant behaviour already. Roger
tritest.tr <- tri.mesh(mydata$x,mydata$y) tritest.nb<- neighbours(tritest.tr) class(tritest.nb) [1] "list" how can I get tritest.tr to a nb object? Or there is another way ? Do I need necessarily a gal file? as I've seen in the examples. Thanks Anna
sessionInfo()
R version 2.9.0 Patched (2009-05-03 r48460) i686-pc-linux-gnu locale: LC_CTYPE=en_US.UTF-8;LC_NUMERIC=C;LC_TIME=en_US.UTF-8;LC_COLLATE=en_US.UTF-8;LC_MONETARY=C;LC_MESSAGES=en_US.UTF-8;LC_PAPER=en_US.UTF-8;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=en_US.UTF-8;LC_IDENTIFICATION=C attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] tripack_1.2-11 nlme_3.1-91 MASS_7.2-47 xtable_1.5-5 [5] lattice_0.17-25 sp_0.9-36 sqldf_0-1.4 gsubfn_0.3-8 [9] proto_0.3-8 RSQLite_0.7-1 DBI_0.2-4 foreign_0.8-35 loaded via a namespace (and not attached): [1] grid_2.9.0 tcltk_2.9.0 tools_2.9.0 Anna Freni Sterrantino Ph.D Student Department of Statistics University of Bologna, Italy via Belle Arti 41, 40124 BO. [[alternative HTML version deleted]]
_______________________________________________ R-sig-Geo mailing list R-sig-Geo at stat.math.ethz.ch https://stat.ethz.ch/mailman/listinfo/r-sig-geo
Roger Bivand Economic Geography Section, Department of Economics, Norwegian School of Economics and Business Administration, Helleveien 30, N-5045 Bergen, Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43 e-mail: Roger.Bivand at nhh.no