"spatial.neighbor"
Objects
spatial.neighbor
which may exist if the neighbor relationships are known to be symmetric.
spatial.condense(neighbor, symmetric=attr(neighbor, "symmetric"))
"spatial.neighbor"
containing the sparse matrix
representation of the spatial neighbor matrix (or matrices). See function
spatial.neighbor
.
TRUE
, asymmetric terms in the neighbor object are removed
and the symmetric attribute of the resulting object is reset to
TRUE
.
"spatial.neighbor"
representing the same sparse
matrix as the input object, but with redundant entries removed. No
attempt at combining entries is made. If an entry is determined to be
redundant, it is removed.
Argument
neighbor
is a sparse matrix representation of one or more
matrices. It must be an object of class
"spatial.neighbor"
.
Let
a[i,j]
denote an element of one such
matrix. Then if
a[i,j]
is not zero, regions
i
and
j
are neighbors,
and the strength of the relationship is given by the
magnitude of
a[i,j]
.
If the object of class
"spatial.neighbor"
is labeled
symmetric, then only one of
a[i,j]
or
a[j,i]
is needed to specify it.
In the case of the object having more than one neighbor matrices (i.e.
attribute `nregion>1'), the k-th matrix may be combined with the
l-th matrix. It is again possible that two different values for
a[i,j]
might be defined. Routine
spatial.condense
eliminates the redundant
values by removing all but one reference to each neighbor pair from
all matrices corresponding to the spatial neighbor object.
index.rows <- c(1,1,2,2,3) index.cols <- c(2,3,1,3,4) my.neighbor <- spatial.neighbor(row.id=index.rows, col.id=index.cols) attr(my.neighbor, "symmetric") <- T # The default had set it to FALSE print(my.neighbor) print(spatial.weights(my.neighbor)) my.neighbor <- spatial.condense(my.neighbor) print(my.neighbor) print(spatial.weights(my.neighbor))