[R-sig-Geo] help

Roger Bivand Roger.Bivand at nhh.no
Thu Apr 5 09:49:56 CEST 2018


On Thu, 5 Apr 2018, Yalemzewod Gelaw wrote:

> I am a new student to R learning for spatial analysis. I was hoping someone
> could help me with the
> error message I keep getting when I try to convert the neighbour data to a
> listw object use the nb2listw()  function.
>
> plot(xw_nbq, coords,add=TRUE,col="red")> summary(xw_nbq)
>
>
> Neighbour list object:
> Number of regions: 140
> Number of nonzero links: 680
> Percentage nonzero weights: 3.469388
> Average number of links: 4.857143
> 2 regions with no links:
> 3 138
> Link number distribution:
>
> 0  1  2  3  4  5  6  7  8  9
> 2  6  4 16 32 35 17 13 13  2
> 6 least connected regions:
> 11 32 57 117 124 137 with 1 link
> 2 most connected regions:
> 28 71 with 9 links
>
> ​when I try to run nb2listw, i got repated error following the below error
> message. ​
>
> xlist <- nb2listw(neighbours,glist = NULL,style = "W",zero.policy
> =TRU) > summary.listw(xlist)
> Error in summary.listw(xlist) : regions with no neighbours found, use
> zero.policy=TRUE

Please do not send HTML-formatted messages.

You need to continue using zero.policy=TRUE when using an object created 
with no-neighbour observations. You can also set a pre-session global 
option using set.ZeroPolicyOption(TRUE), which is checked first in 
functions using the zero.policy= argument. set.ZeroPolicyOption(TRUE) 
outputs the value of get.ZeroPolicyOption() before making the change.

You should always find out why you have no-neighbour observations. From 
your attached image, it looks as though you have a faulty set of polygons, 
and have used poly2nb() to find border contiguities. My guess is that the 
polygons with no neighbours have borders that almost touch - look at the 
snap= argument in poly2nb(). There are also other near-contiguities to be 
found - had the input boundaries been line-generalized?

Roger

>
> I wonder if someone advises me how to fix the error message from my working
> directory
>>
>
> *Regards, *
>
> Yalem
>

-- 
Roger Bivand
Department of Economics, Norwegian School of Economics,
Helleveien 30, N-5045 Bergen, Norway.
voice: +47 55 95 93 55; e-mail: Roger.Bivand at nhh.no
http://orcid.org/0000-0003-2392-6140
https://scholar.google.no/citations?user=AWeghB0AAAAJ&hl=en


More information about the R-sig-Geo mailing list