Search code examples
rimageraster

function stack image in R


I would like to perform an analysis on images located in a specific folder. I use:

library(raster)
folder <- "C:/Users/Mezeix/Pictures/FreeVideoToJPGConverter/1 images/"
img <- list.files(folder) 
img.raster<-stack(img)

I started with only 1 image to check. As observed the image is well stored into "img "

enter image description here

But when I use the function stack(img) I have the following message:

Error in .local(.Object, ...) : 
Error in .rasterObjectFromFile(x, band = band, objecttype = "RasterLayer",  : 
  Cannot create a RasterLayer object from this file. (file does not exist)

I do not understand why.


Solution

  • It will work if you use

    img <- list.files(folder, full.names=TRUE)