Я наконец-то воспользовался этой функцией, и она заработала:
dempath = "./dem/dem.asc"
output = "./output/"
crs(dem) <- epsg
#CREATE DEM PRODUCTS IN PARALLEL
demproductspar <- function(dempath, output, epsg = crs('+init=epsg:25829'), cor = 3){
print ('Leyendo dem...')
dem = raster(dempath)
crs(dem) <- epsg
plan(multiprocess, workers = cor, gc = TRUE)
plan(multiprocess, workers = availableCores(), gc = TRUE)
f1 <- future({ terrain(dem, filename = paste0(output,"01_slope.asc"), opt = "slope", unit = 'degrees', neighbors = 8) })
f2 <- future({
terrain(dem, filename = paste0(output,"02_aspect.asc"), opt = "aspect", unit = 'degrees', neighbors = 8)
aspectreclass(aspectdir = paste0(output,"02_aspect.asc"), output = paste0(output,"02r_aspect.asc")) })
f3 <- future({ terrain(dem, filename = paste0(output,"03_roughness.asc"), opt = "roughness", unit = 'degrees', neighbors = 8) })
f4 <- future({ terrain(dem, filename = paste0(output,"04_tri.asc"), opt = "tri", unit = 'degrees', neighbors = 8) })
f5 <- future({ terrain(dem, filename = paste0(output,"05_tpi.asc"), opt = "tpi", unit = 'degrees', neighbors = 8) })
print ('Procesando dem...')
f1; f2; f3; f4; f5
gc()
}
demproductspar(dempath, output)