mask not using rasterOptions(tmpdir)

Issue #7 open
Guillaume Drolet repo owner created an issue

Line 141 in fmask.R:

r <- mask(r, n.ms, maskvalue = 0)

does not write to tmpdir even if rasterOptions(tmpdir = outdir) is called before running fmask() and most temporary rasters are effectively written to outdir. Looks like a bug in raster::mask.

Tried: r <- mask(r, n.ms, maskvalue = 0, filename = rasterTmpFile())

Didn't work. Still writing to C:\Users...\ (which is not the working directory) and filling up memory, which results in a crash of the function.

Comments (8)

  1. etiennebr

    Add

    clusterExport(cl, list(op = rasterOptions()))
    clusterEvalQ(cl, c(library(raster), library(rgdal), rasterOptions(op))
    
  2. Guillaume Drolet reporter

    added:

    td <- options("rasterTmpDir")[[1]]
    clusterExport(cl, list("td"), envir = environment())
    clusterEvalQ(cl, c(library(raster), library(rgdal), rasterOptions(tmpdir = td)))
    
  3. etiennebr

    Is it robust ? Can you do that in a new session where rasterOptions() has never been called ? Doesn't seem to work.

  4. Guillaume Drolet reporter

    its not robust and I experienced it this afternoon when I ran the code without first calling rasterOptions(tmpdir = tmpdir). It's a temporary fix...

  5. Guillaume Drolet reporter

    Temporary: clunky but it works IF you do the right things.

    Guillaume Drolet ing.f M.Sc. Chercheur en télédétection et dynamique forestière Direction de la recherche forestière Ministère des ressources naturelles du Québec Québec (Québec), Canada G1P 3W8 T : +1 418 643 7994 #6727 F : +1 418 643 2165

    http://www.mrn.gouv.qc.ca/forets

  6. etiennebr

    We should probably get rid of rasterOptions() and explicitly load the appropriate parameters. See #24 for other problems.

  7. Log in to comment