[R-sig-Geo] How do I calculate neighborhood contiguity in R?
Shanley Thompson
sdthomps at uvic.ca
Tue Aug 26 02:57:39 CEST 2014
Hello,
My end goal is to calculate join counts, using the function
joincounts.multi() from the R package spdep. I understand that first I need
to calculate the nb object, then the spatial weights matrix, then I can do
the join counts.
I have a very large raster file (nrows = 19663, ncols = 34073), with cell
size of 30 m, in integer format. I read it in using the raster() function
from the Raster package.
For the first part (creating a "nb" object), I have tried using the cell2nb
file but it keeps crashing - a quick search tells me others have had the
same problem due to large files.
I read that one can use "dnearneigh" function in the spdep package instead,
but I do not understand how to do so. Can someone provide a detailed
example? Alternatively, would it be better to convert my raster layer to a
polygon layer then use the function poly2nb?
I am relatively new to R so the simpler the better!
Thank you so much!
Shanley Thompson, MSc, PhD Candidate
Department of Geography, University of Victoria, Canada
More information about the R-sig-Geo
mailing list