[R] Spatial Ananlysis: zero.policy=TRUE doesn't work for no neighbour regions??

Roger Bivand Roger.bivand at nhh.no
Wed Apr 17 12:28:37 CEST 2013

Molo <kurz_m <at> uni-hohenheim.de> writes:

> *As there are some regions without neighbours in my data I use the following
> code to create the Weights Matrix:*
> > W_Matrix<- nb2listw(location_nbq, style="W", zero.policy=TRUE)
> >W_Matrix
> *And get this Output:*
> /("Error in print.listw(list(style = "W", neighbours = list(c(23L, 31L, 42L
> : 
>   regions with no neighbours found, use zero.policy=TRUE")/
> As I use "zero.policy=TRUE" I just don't understand what I'm doing wrong...
> My question would be: How could I create a Weights Matrix allowing for
> no-neighbour areas? 

You have not grasped the fact that your object W_Matrix has been created
correctly, but that spdep:::print.listw also needs a zero.policy=TRUE, so:

print(W_Matrix, zero.policy=TRUE)

will work. If you want to set this globally for all subsequent function
calls in your current session, use set.ZeroPolicyOption(TRUE).

Hope this clarifies,


PS. Consider posting questions of this kind to R-sig-geo

> Thanks
> Michael

More information about the R-help mailing list