[R-sig-Geo] Producing a conditional adjacency matrix
Roger@B|v@nd @end|ng |rom nhh@no
Tue Oct 1 12:22:40 CEST 2019
On Mon, 30 Sep 2019, Rhys Dubin wrote:
> Hi all,
> I have a question regarding matrices (produced using poy2nb in spdep).
> I’m trying to produce an adjacency matrix from a GIS Polygon shapefile
> with about 500 individual polygons (queen or rook — it doesn’t really
> matter for now), but conditional on the value of the parent polygon.
> For instance, if a polygon had an arbitrary value of 1, I want to return
> a list of all neighboring polygons that have a value of 2 or 3 (ie. ≠
> 1). The same would go for a polygon with a value of 2 (ie. return all
> neighbors with a value of ≠ 2).
> Is there a solution to this issue built into spdep, do I need to use a
> different package, or is it possible to accomplish this with a
> subsetting command?
No built-in solution, but to make progress a clear, reproducible example
is essential, otherwise we're guessing what you want. For example, add a
doctored variable to the eire or columbus data sets to show your needs. Do
you want a glist including (1) all neighbours j with a value of x not
equal to x[i], and excluding (0) all with x[j] == x[i]?
> R-sig-Geo mailing list
> R-sig-Geo using r-project.org
Department of Economics, Norwegian School of Economics,
Helleveien 30, N-5045 Bergen, Norway.
voice: +47 55 95 93 55; e-mail: Roger.Bivand using nhh.no
More information about the R-sig-Geo