I'm trying to combine a large number of raster tiles to a single mosaic using R codes as follows. The error that appears is:
Error in if (xn == xx) { : missing value where TRUE/FALSE needed
The error appears after the for loop.
I will highly appreciate your suggestion.
require(raster)
rasters1 <- list.files("D:/lidar_grid_metrics/ElevMax",
pattern="*.asc$", full.names=TRUE, recursive=TRUE)
rast.list <- list()
for(i in 1:length(rasters1)) { rast.list[i] <- raster(rasters1[i]) }
rast.list$fun <- mean
rast.mosaic <- do.call(mosaic,rast.list)
plot(rast.mosaic)