ascii - In R create maximum raster from mulitple raster files -


i kind of new r maybe stupid question cant figure out myself.

this problem. have multiple asc files same gridsize , cover same area. want maximum value each grid asc files. tried multiple things:

   (i in 1:144){     asc0<-rastertopoints(raster(asc0))         asc1<-rastertopoints(raster(asc[i]))         asc0[,3] <-pmax(asc0[,3], asc1[,3])     } 

this 1 fails when loop threw files, becasue leaves out na, asc0 (my base file) different size next file asc1[2].

does know way this? have loops ready go through files, there 13x144 files. cant figure out way maximum value, store it, , compare next file.

thanks, appriciate help!!!

use stack , max:

r1 <- r2 <- r3 <- raster(nrows=10, ncols=10, xmn=0, xmx=10, ymn=0, ymx=10) r1[] <- 1   # raster 1 r2[] <- 2   # raster 2 r3[] <- 3   # raster 3 s1 <- stack(r1, r2, r3) s1 #class       : rasterstack  #dimensions  : 10, 10, 100, 3  (nrow, ncol, ncell, nlayers) #resolution  : 1, 1  (x, y) #extent      : 0, 10, 0, 10  (xmin, xmax, ymin, ymax) #coord. ref. : +proj=longlat +datum=wgs84 +ellps=wgs84 +towgs84=0,0,0  #names       : layer.1, layer.2, layer.3  #min values  :       1,       2,       3    <- values between 1 , 3 #max values  :       1,       2,       3    <- values between 1 , 3  max(s1) #class       : rasterlayer  #dimensions  : 10, 10, 100  (nrow, ncol, ncell) #resolution  : 1, 1  (x, y) #extent      : 0, 10, 0, 10  (xmin, xmax, ymin, ymax) #coord. ref. : +proj=longlat +datum=wgs84 +ellps=wgs84 +towgs84=0,0,0  #data source : in memory #names       : layer  #values      : 3, 3  (min, max)   <- 3 

Comments

Popular posts from this blog

python - No exponential form of the z-axis in matplotlib-3D-plots -

php - Best Light server (Linux + Web server + Database) for Raspberry Pi -

c# - "Newtonsoft.Json.JsonSerializationException unable to find constructor to use for types" error when deserializing class -