Skip to content
Prev 9674 / 12125 Next

[R-pkg-devel] Error: [writeRaster] cannot write file

You wrote

# create the plots directory if it does not exist

but then created a directory named outdir/plots/typ_Sys.time.tif

You need to rewrite the code like:

plotsdir <- file.path(outdir, "plots")
fp <- file.path(plotsdir,  paste(typ, "_",
    stringr::str_replace_all(Sys.time(), "[^a-zA-Z0-9]", ""),
                                ".tif", sep = ""))
# Create the "plots" directory if it doesn't exist
  if (!dir.exists(plotsdir)) {
    dir.create(plotsdir, recursive = TRUE)
  }
On Mon, Oct 9, 2023, 15:49 Keshav, Krishna <kkeshav at ufl.edu> wrote:

            

  
  
Message-ID: <CADNULg_xAggbz+JGMh=UeK9EBizAf29AcwCyEMsqaoGJOtE55A@mail.gmail.com>
In-Reply-To: <SJ0PR22MB2448CB5ADC64FF3B1C14B977B6CEA@SJ0PR22MB2448.namprd22.prod.outlook.com>