[R-sig-Geo] Neighborhood weights spam matrix

Nikhil Kaza nikhil.list at gmail.com
Thu Feb 18 13:49:58 CET 2010


Hello,

I am not sure if this is the right forum to ask as this is mostly a  
sparse matrix question, nevertheless here it is.

I am using R - 2.10.1 and spdep 0.4-54 on Windows Vista

I have a large shapefile for which I need to create a neighborhood  
matrix file, I used the following command to create a neighborhood  
matrix

shp_file <- readShapePoly(file.choose())
grid_nb_mat <- as.spam.listw(nb2listw(poly2nb(shp_file,  
row.names=shp_file$CELL_ID)))

Now I would like to subset this matrix based on a subset of the  
shapefile and I have a vector of CELL_IDs. However, I cannot figure  
out a way to assign row and column names to grid_nb_mat, so that I can  
subset this matrix. Could someone point me in the right direction? If  
it is were a simple matrix row.names and colnames would work.

regards
Nikhil



More information about the R-sig-Geo mailing list