I am kind of new R so maybe its a stupid question but i cant figure it out myself.
This is my problem. I have multiple asc files with the same gridsize and cover the same area. I want to get the maximum value for each grid from all the asc files. I tried multiple things:
for (i in 1:144){
asc0<-rasterToPoints(raster(asc0))
asc1<-rasterToPoints(raster(asc[i]))
asc0[,3] <-pmax(asc0[,3], asc1[,3])
}
This one fails when I loop threw the files, becasue it leaves out the NA, so my asc0 (my base file) is a different size than my next file asc1[2].
Does anyone know a way to this? I have my loops ready to go through all the files, there are 13x144 files. But I cant figure out a way to get the maximum value, store it, and compare it to the next file.
Thanks, really appriciate your help!!!
Use
stack
andmax
: