[R-sig-Geo] simulated rasters?
Robert J. Hijmans
r.hijmans at gmail.com
Fri Jun 3 19:42:02 CEST 2011
Hi Agus,
I have implemented a similar function in raster version 1.8-31, such
that you can coerce from grf to Raster* objects
library(geoR)
library(raster)
sim <- grf(441, grid="reg", cov.pars=c(1, .25), nsim=4)
b <- brick(sim)
# or
x <- as(b, 'RasterBrick')
# and
r <- raster(sim)
r <- raster(sim, 2)
Not much tested or optimized, obviously.
Best,
Robert
On Fri, Jun 3, 2011 at 9:36 AM, Agustin Lobo <alobolistas at gmail.com> wrote:
> Hi!
>
> Could raster inherit from grf objects (package geoR)?
> It would be useful to generate simulated raster fields.Or perhpas is there
> a way of doing this with another package?
>> sim <- grf(441, grid="reg", cov.pars=c(1, .25), nsim=4)
>> simr = raster(sim)
> Error in function (classes, fdef, mtable) :
> unable to find an inherited method for function "raster", for signature "grf"
>
> By now I use
>> a = (sim$data)
>> dim(a) <- c(21,21)
>> simr = raster(t(a)[21:1,])
>
> Thanks,
>
> Agus
>
More information about the R-sig-Geo
mailing list