Search code examples
rfunctionerror-handlingrastertiff

Issue with writeRaster function


I have this piece of code:

library(rgdal)
writeRaster("~/xxxxx/xxxxx/xxxx/namefile.tif", layer="namefile", driver="GeoTiff", overwrite = TRUE)

And the following error message:

Error in (function (classes, fdef, mtable) : unable to find an inherited method for function 'writeRaster' for signature '"character", "missing"'

Does someone know what's wrong?

Many thanks.


Solution

  • What are you trying to write to a file? writeRaster expects a variable name as the first argument:

    writeRaster(my.raster.object, "~/xxxxx/xxxxx/xxxx/namefile.tif", layer="namefile", driver="GeoTiff", overwrite = TRUE)