I am trying to save different objects resulting from loop. I am using the funcion raster
to charge multiple images in different directories,the loop generetes these objects:
b : it generates the different directories where I have my images
[1] "C:/Users/franc/Documents/Fran/Tesis/Sin sincronizar/Imagenes Landsat/1985/Invierno/band3.tif"
[1] "C:/Users/franc/Documents/Fran/Tesis/Sin sincronizar/Imagenes Landsat/1986/Invierno/band3.tif"
[1] "C:/Users/franc/Documents/Fran/Tesis/Sin sincronizar/Imagenes Landsat/2004/Invierno/band3.tif"
name: the different names that I want to use to save the outputs
[1] "1985Banda3"
[1] "1986Banda3"
[1] "2004Banda3"
Then I want to use the directory b to charge the images, and save each one in each value of name
Here is my code:
library(raster)
a<-c(1985,1986,2004)
i<-1
while(i<=(length(a)))
{
b<-paste("C:/Users/franc/Documents/Fran/Tesis/Sin sincronizar/Imagenes Landsat/",a[[i]],
"/Invierno/band3.tif", sep = '')
name<-(paste(a[[i]],"Banda3", sep =''))
name<- raster(b)
i<-i+1
}
I want to generete this
1985Banda3 <- raster( "C:/Users/franc/Documents/Fran/Tesis/Sin sincronizar/Imagenes Landsat/1985/Invierno/band3.tif")
1986Banda3 <- raster( "C:/Users/franc/Documents/Fran/Tesis/Sin sincronizar/Imagenes Landsat/1986/Invierno/band3.tif")
2004Banda3 <- raster( "C:/Users/franc/Documents/Fran/Tesis/Sin sincronizar/Imagenes Landsat/2004/Invierno/band3.tif")