listw2sn.Rd
The function makes a "spatial neighbour"
object representation
(similar to the S-PLUS spatial statististics module representation of a
"listw"
spatial weights object. sn2listw()
is the inverse function to listw2sn()
, creating a "listw"
object from a "spatial neighbour"
object.
listw2sn(listw)
sn2listw(sn)
a listw
object from for example nb2listw
a spatial.neighbour
object
listw2sn()
returns a data frame with three columns, and with class spatial.neighbour
:
region number id for the start of the link (S-PLUS row.id)
region number id for the end of the link (S-PLUS col.id)
weight for this link
columbus <- st_read(system.file("shapes/columbus.shp", package="spData")[1], quiet=TRUE)
col.gal.nb <- read.gal(system.file("weights/columbus.gal", package="spData")[1])
col.listw <- nb2listw(col.gal.nb)
col.listw$neighbours[[1]]
#> [1] 2 3
col.listw$weights[[1]]
#> [1] 0.5 0.5
col.sn <- listw2sn(col.listw)
str(col.sn)
#> Classes ‘spatial.neighbour’ and 'data.frame': 230 obs. of 3 variables:
#> $ from : int 1 1 2 2 2 3 3 3 3 4 ...
#> $ to : int 2 3 1 3 4 1 2 4 5 2 ...
#> $ weights: num 0.5 0.5 0.333 0.333 0.333 ...
#> - attr(*, "n")= int 49
#> - attr(*, "region.id")= chr [1:49] "1" "2" "3" "4" ...
#> - attr(*, "neighbours.attrs")= chr [1:6] "class" "region.id" "GeoDa" "gal" ...
#> - attr(*, "weights.attrs")= chr [1:3] "mode" "W" "comp"
#> - attr(*, "GeoDa")=List of 2
#> ..$ shpfile: chr NA
#> ..$ ind : chr NA
#> - attr(*, "listw.call")= language nb2listw(neighbours = col.gal.nb)