[R] StackRaster problem

Jon Skoien jon.skoien at jrc.ec.europa.eu
Tue Aug 26 17:15:32 CEST 2014


Did you attach the raster package with library(raster)? It seems the 
newest version of dismo does not depend on raster, so you will not be 
able to use raster-functions if you only attach dismo.
This error message typically comes when R tries to use 
utils:::stack.default instead of the stack-function defined in the 
raster-package.

If this is not the case, please give the output from sessionInfo().

Cheers,
Jon

On 8/26/2014 3:21 PM, Guilherme Leite wrote:
> Hi,
>
> This is the process I want to do:
>
>> files <- list.files(path=paste(system.file(package="dismo"), '/ex',
> sep=''), pattern='grd', full.names=TRUE )
>
>> # The above finds all the files with extension "grd" in the
>> # examples ("ex") directory of the dismo package. You do not
>> # need such a complex statement to get your own files.
>
>> files
> [1] "d:/temp/Rtmp8Mttik/Rinst1fe4202d2ea5/dismo/ex/bio1.grd"
> [2] "d:/temp/Rtmp8Mttik/Rinst1fe4202d2ea5/dismo/ex/bio12.grd"
> [3] "d:/temp/Rtmp8Mttik/Rinst1fe4202d2ea5/dismo/ex/bio16.grd"
> [4] "d:/temp/Rtmp8Mttik/Rinst1fe4202d2ea5/dismo/ex/bio17.grd"
> [5] "d:/temp/Rtmp8Mttik/Rinst1fe4202d2ea5/dismo/ex/bio5.grd"
> [6] "d:/temp/Rtmp8Mttik/Rinst1fe4202d2ea5/dismo/ex/bio6.grd"
> [7] "d:/temp/Rtmp8Mttik/Rinst1fe4202d2ea5/dismo/ex/bio7.grd"
> [8] "d:/temp/Rtmp8Mttik/Rinst1fe4202d2ea5/dismo/ex/bio8.grd"
> [9] "d:/temp/Rtmp8Mttik/Rinst1fe4202d2ea5/dismo/ex/biome.grd"
>
>> predictors <- stack(files)
>> predictors
>
> class : RasterStack
> dimensions : 192, 186, 35712, 9 (nrow, ncol, ncell, nlayers)
> resolution : 0.5, 0.5 (x, y)
> extent : -125, -32, -56, 40 (xmin, xmax, ymin, ymax)
> coord. ref. : +proj=longlat +datum=WGS84 +ellps=WGS84 +towgs84=0,0,0
> names : bio1, bio12, bio16, bio17, bio5, bio6, bio7, bio8, biome
> min values : -23, 0, 0, 0, 61, -212, 60, -66, 1
> max values : 289, 7682, 2458, 1496, 422, 242, 461, 323, 14
>
> But what happen is:
>
>> files <- list.files(path=paste(system.file(package="dismo"), '/ex',
> sep=''), pattern='grd', full.names=TRUE )
>
>> files
>
> [1] "d:/temp/Rtmp8Mttik/Rinst1fe4202d2ea5/dismo/ex/bio1.grd"
> [2] "d:/temp/Rtmp8Mttik/Rinst1fe4202d2ea5/dismo/ex/bio12.grd"
> [3] "d:/temp/Rtmp8Mttik/Rinst1fe4202d2ea5/dismo/ex/bio16.grd"
> [4] "d:/temp/Rtmp8Mttik/Rinst1fe4202d2ea5/dismo/ex/bio17.grd"
> [5] "d:/temp/Rtmp8Mttik/Rinst1fe4202d2ea5/dismo/ex/bio5.grd"
> [6] "d:/temp/Rtmp8Mttik/Rinst1fe4202d2ea5/dismo/ex/bio6.grd"
> [7] "d:/temp/Rtmp8Mttik/Rinst1fe4202d2ea5/dismo/ex/bio7.grd"
> [8] "d:/temp/Rtmp8Mttik/Rinst1fe4202d2ea5/dismo/ex/bio8.grd"
> [9] "d:/temp/Rtmp8Mttik/Rinst1fe4202d2ea5/dismo/ex/biome.grd"
>
>> predictors <- stack(files)
> Error in rep.int(names(x), lapply(x, length)) : invalid 'times' value
>
> Do you know how to fix it?
>
> Thank you,
> Guilherme
>
> 	[[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

-- 
Jon Olav Skøien
Joint Research Centre - European Commission
Institute for Environment and Sustainability (IES)
Climate Risk Management Unit

Via Fermi 2749, TP 100-01,  I-21027 Ispra (VA), ITALY

jon.skoien at jrc.ec.europa.eu
Tel:  +39 0332 789205

Disclaimer: Views expressed in this email are those of the individual 
and do not necessarily represent official views of the European Commission.



More information about the R-help mailing list