[R-sig-Geo] no slot of name "data" for this object of class "RasterStack"

Robert Hijmans r.hijmans at gmail.com
Thu Jan 6 19:25:51 CET 2011


Hi Peter, 

I think you have made things way too complicated. I would suggest to do
something along these lines:

library(raster) 
# first get the filenames. 
vargroup <- c("bio","prec","tmax","tmin","tmean") 
filenames <- list()
for (v in vargroup) { 
	filenames <- c(filenames, list.files(path=paste("../WC_10min/", v, sep=""),
pattern=v) 
} 
# or perhaps even this would work (I am not sure what your file name pattern
is):
# filenames <- c(filenames, list.files(path="../WC_10min/", pattern=".grd",
recursive=TRUE) 

# then make a stack
s <- stack(filenames)
# get all the values
v <- getValues(s)


# Studying the raster vignette might also be a good idea

# For readability, instead of 
extent <- extent(mask) 
xmin <- attributes(extent)$xmin 
# you can do
xmin <- xmin(mask)
# and
xlength <- dim(mask)[2] 
# is equivalent to
xlength <- ncol(mask) 



Best, Robert

-- 
View this message in context: http://r-sig-geo.2731867.n2.nabble.com/no-slot-of-name-data-for-this-object-of-class-RasterStack-tp5896279p5896604.html
Sent from the R-sig-geo mailing list archive at Nabble.com.



More information about the R-sig-Geo mailing list