pe_tsa
pe_tsa

Reputation: 13

Merge 1000 transparent png files in one

I'm trying to merge (overlaying) ~1000 (12MB total) transparent images *.png in one png or other raster file. Which package or function in R must be use?

The images contains radar cloud data. Evrey day the radar makes ~350 png. Sample: 001, 002, 003, 004

Here is the legend of colors legend

After that i will compare the result with data from 120 rain gauges.

Now i use this code

library(base)
library(png)

homeserverDir = "S:/R/radarTEST"
dDir_new = paste(homeserverDir, "dd_stack", sep = "/")
rr_dir = paste(homeserverDir, "dd_stackD", sep = "/")

setwd(dDir_new)
filenames <- list.files(path = dDir_new, pattern="*.png")
theATs <- lapply(filenames, raster)

STACK1 <- stack(theATs)

res <- Reduce("+", theATs, accumulate = TRUE)

setwd(rr_dir)

lapply(seq_along(res), function(x) {
  writeRaster(res[[x]], paste(filenames[x], "_cumsum", sep = ""), datatype = 'FLT4S', overwrite = TRUE)
})


Grids_list = list.files(rr_dir, "grd")
Radar_sum = raster(Grids_list[length(Grids_list)])

plot(Radar_sum)

Upvotes: 1

Views: 78

Answers (0)

Related Questions