[R] StackRaster problem
Guilherme Leite
guilhermeleite.bio at gmail.com
Tue Aug 26 15:21:06 CEST 2014
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]]
More information about the R-help
mailing list