Search code examples
rrasterr-rastermosaic

What does raster$fun do?


I am trying to use the code referenced in this post but I can't figure out why it is necessary to run raster.list$fun = mean. (See answers in link) Can anyone tell me what this does?


Solution

  • When you are using do.call() you have to supply your arguments as a list:

    In the provided link the do.call function is used to mosaic a list of raster images. So the first argument of the function do.call() is always the function you want to use (in this case mosaic), and the sencond argument would be a list of additional parameters. In this case the raster images plus a function that should be used for overlapping areas during the mosaicing (here mean).

    So by typing raster.list$fun = mean you just add a new element called "fun" to the list, that contains the r-base function mean(). This will then be used as an input for the mosaic function invoked by do.call.

    For more information please look up the help pages for ?do.call and ?mosaic. Hope this helps.