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, style = NULL, zero.policy = NULL, from_mat2listw=FALSE)
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
a listw
object from for example nb2listw
a spatial.neighbour
object
default NULL, missing, set to "M" and warning given; if not "M", passed to nb2listw
to re-build the object
default NULL, use global option value; if FALSE stop with error for any empty neighbour sets, if TRUE permit the weights list to be formed with zero-length weights vectors
default FALSE, set TRUE if called from mat2listw
Roger Bivand Roger.Bivand@nhh.no
nb2listw
columbus <- st_read(system.file("shapes/columbus.gpkg", 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]]
col.listw$weights[[1]]
col.sn <- listw2sn(col.listw)
str(col.sn)
Run the code above in your browser using DataLab