[R-sig-Geo] How to create a regular grid?

Barry Rowlingson b.rowlingson at lancaster.ac.uk
Wed Apr 11 18:19:07 CEST 2018


`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 <roberto.patuelli at unibo.it
> 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
> R-sig-Geo at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>

	[[alternative HTML version deleted]]



More information about the R-sig-Geo mailing list