[R-sig-Geo] create raster using extent and resolution?

Barry Rowlingson b.rowlingson at lancaster.ac.uk
Fri Jul 15 13:27:51 CEST 2011


On Fri, Jul 15, 2011 at 12:00 PM, Agustin Lobo <alobolistas at gmail.com> wrote:
> Hi!
>
> Is it possible to create a raster object using extent and resolution,
> thus having
> raster() to calculate the required nb. of rows and columns? Something like,
>
> a = raster (ext=miextent, res=100)
>
> (Obviously the nb. of pixels would have to be rounded)

In two steps: create the raster and then set the resolution using "res<-"

> e
class       : Extent
xmin        : 178400
xmax        : 181600
ymin        : 329400
ymax        : 334000
> a = raster(e); res(a)=c(100,100)
> a
class       : RasterLayer
dimensions  : 46, 32, 1472  (nrow, ncol, ncell)
resolution  : 100, 100  (x, y)
extent      : 178400, 181600, 329400, 334000  (xmin, xmax, ymin, ymax)
coord. ref. : NA
values      : none

- it chooses the dimensions, rounding if necessary.

Barry



More information about the R-sig-Geo mailing list