[R] Import multiple tif raster

sibyiie@stoeckii m@iii@g oii gmx@ch sibyiie@stoeckii m@iii@g oii gmx@ch
Thu Apr 18 11:08:33 CEST 2024

Dear community

My aim is to import multiple .tif raster files using the help here:

Does anyone now about the error "subscripts out of bounds"?
I am not sure about the check with alllrasters: is list() ok or should there
be a number (the number of imported .tif files?

Kind regards

> library(terra)
> library(raster)
> getwd()
[1] "C:/Users/Sibylle Stöckli/Desktop"
> #first import all files in a single folder as a list 
> rastlist <- list.files(path =
pattern='.tif$', all.files= T, full.names= T)
> #import all raster files in folder using lapply
> allrasters <- lapply(rastlist, raster)
> #to check the index numbers of all imported raster list elements
> allrasters
> #call single raster element
> allrasters[[1]]
Error in allrasters[[1]] : subscript out of bounds

More information about the R-help mailing list