`cell2nb` in spdep will do exactly that: library(sp) library(spdep) plot(cell2nb(5,5),coords=expand.grid(1:5,1:5))
If you want the points as sp class objects, feed SpatialPoints from expand.grid: pts = sp::SpatialPoints(expand.grid(x=1:N,y=1:N)) Barry On Wed, Apr 11, 2018 at 4:31 PM, Roberto Patuelli <[email protected] > wrote: > Dear All, > > Maybe a basic question: > > How can I create - for simulation purposes - a regular grid (a raster) N > by N on which to generate a rook spatial weights matrix (listw or nb > object)? > > I actually only need to obtain the listw/nb object for such regular grid. > > It feels like this is very simple, but somehow I'm stuck. > > Thanks > Roberto > > ******************** > Roberto Patuelli, Ph.D. > Department of Economics > University of Bologna > Rimini campus > Italy > > _______________________________________________ > R-sig-Geo mailing list > [email protected] > https://stat.ethz.ch/mailman/listinfo/r-sig-geo > [[alternative HTML version deleted]] _______________________________________________ R-sig-Geo mailing list [email protected] https://stat.ethz.ch/mailman/listinfo/r-sig-geo
