Skip to content
Prev 8137 / 29559 Next

ArcGIS SWMs in R

On Mon, 26 Apr 2010, Scott L Minkoff wrote:

            
That helps a little - the output of traceback() would have helped more, 
and shows (by grepping the source code) that the error occurs in 
listw2mat(), so at least one of listw$neighbours[[i]]] is an NA. Since I 
have a copy of the input data file, I see that:
Min. 1st Qu.  Median    Mean 3rd Qu.    Max.    NA's
     2.0   336.0   668.0   667.9  1006.0  1330.0   137.0

If you form the sn object dropping the possibly spurious +1 in 
to=match(xx$NID+1, to_IDs):

sn <- data.frame(from=match(xx$FID2, from_IDs), to=match(xx$NID,
    to_IDs), weights=xx$WEIGHT)

the sn object converts to a listw object and on to a matrix without 
complaining. match() by default returns NA when no match is found. I think 
the original +1 came from being misled by the 0-base in the FID values.

Hope this helps,

Roger