When I used writeRaster() in R, I got the error like this: Error in .startGDALwriting(x, filename, gdal = options, ...): 'file' slot name does not exist in the object of the 'RasterStack' class.
Does anyone know how to deal with it?
When I used writeRaster() in R, I got the error like this: Error in .startGDALwriting(x, filename, gdal = options, ...): 'file' slot name does not exist in the object of the 'RasterStack' class.
Does anyone know how to deal with it?
I had a similar issue.
I created a raster stack with the raster package
raster_stack <- stack(DEM,SLP,TWI,AHS,LSF,CNBL,RSP)
But it was not able to write the raster stack in my file:
writeRaster(raster_stack, "Cov_Stack.tif", format="GTiff", overwrite = TRUE)
Error in .startGDALwriting(x, filename, gdal = options, ...) :
formal argument "sources" matched by multiple actual arguments
So I used the terra package.
test <- rast(raster_stack)
terra::writeRaster(Test, "Cov_Stack.tif")
It's simple but I hope it helps you.