I'm trying to modify a raster through an R script but I find an error when I try to save in the ".tif" format, while in the ".asc" format I do not find any problem. The script I use is as follows:
library(raster) path <- "/path/to/input/file.tif" path2 <- "/path/to/output/file.tif" open_file <- raster(path) rasterzero <- open_file * 0 writeRaster(rasterzero, filename=path2, overwrite=TRUE)
The error I get is the following:
*** caught segfault *** address 0x565300000009, cause 'memory not mapped' Traceback: 1: .Call("RGDAL_SetProject", object, proj4string, PACKAGE = "rgdal") 2: .gd_SetProject(object, ...) 3: rgdal::GDALcall(transient, "SetProject", as.character(projection(r))) 4: .getGDALtransient(x, filename = filename, options = options, ...) 5: .startGDALwriting(y, filename, options, setStatistics = setStatistics, ...) 6: .writeGDALall(x, filename = filename, format = filetype, ...) 7: .local(x, filename, ...) 8: writeRaster(rasterzero, filename = path2, overwrite = TRUE) 9: writeRaster(rasterzero, filename = path2, overwrite = TRUE) Possible actions: 1: abort (with core dump, if enabled) 2: normal R exit 3: exit R without saving workspace 4: exit R saving workspace
Any suggestions on the possible cause? The same script on different computers runs without errors and the installation procedures of R and its packages are always the same.