[R-sig-Geo] rastrer::raster no extent argument?

Robert J. Hijmans r.hijmans at gmail.com
Wed Jun 15 19:07:33 CEST 2011


Agus,

You can do:

foo4 <- raster(nrows=20, ncols=20,crs=NA,extent(0,20,0,20))

#which is the same as
foo4 <- raster(x=extent(0,20,0,20), nrows=20, ncols=20, crs=NA )

#or
foo4 <- raster(nrows=20, ncols=20,crs=NA, xmn=0, xmx=20, ymn=0, ymx=20)

What I will add to the package is the ability to do

foo4 <- raster(nrows=20, ncols=20,crs=NA, ext=c(0,20,0,20))

i.e. ext in stead of xmn, xmx, ymn, ymx. (I am standardizing on "ext"
as the argument name for Extent objects)

Best, Robert


On Wed, Jun 15, 2011 at 7:26 AM, Agustin Lobo <alobolistas at gmail.com> wrote:
> Hi!
>
> In order to define an arbitrary test raster object, I thought I could do:
>> foo4 <- raster(nrows=20, ncols=20,crs=NA,extent=c(0,20,0,20))
>> values(foo4) <- runif(400,-100,150)
>
> but extent is not a valid argument, so I use another step
>> foo4 <- raster(nrows=20, ncols=20,crs=NA)
>> values(foo4) <- runif(400,-100,150)
>> extent(foo4) = extent(c(0,20,0,20))
>
> Would not make sense adding this feature to raster() itself?
>
> Agus
>



More information about the R-sig-Geo mailing list