'Corrupt raster, while merging multiple raster tiles

I have a around 1000 raster tiles. I am trying to merge them as a single raster tile.

library(raster)
raster_tile_path <- list.files("file_path", full.names = TRUE,
                                        pattern = ".tif" ))

merge_tile  <- lapply(raster_tile_path, raster)
merge_tile  <- do.call(merge, c(merge_tile, tolerance = 1))

Upon running, i get this error:

Error in rgdal::getRasterData(con, offset = offs, region.dim = reg, band = object@data@band) : Failure during raster IO

Someone already suggested the source of error: https://stackoverflow.com/a/67607770/9101903 could be a bad or corrupted raster tile. But it seems that there is no solution to identify or ignore this specific raster tile.

Anybody got an idea on how to solve this?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source