title: R: Raster mosaic from list of rasters?
body: <p>I am working from the post here: <a href="https://stackoverflow.com/questions/15287807/how-can-i-create-raster-mosaic-using-list-of-rasters">How can I create raster mosaic using list of rasters?</a> to create a raster mosaic using a list of rasters. The example in the answer given by fmark works perfectly but I get an error when I follow the steps using my own data. Not sure where I am going wrong, any help would be very much appreciated!</p>
  
  <pre><code>R version 2.15.3 (2013-03-01)
  Platform: x86_64-unknown-linux-gnu (64-bit)
  locale:
  [1] C
  attached base packages:
  [1] stats     graphics  grDevices utils     datasets  methods   base
  other attached packages:
  [1] raster_2.2-12 rgdal_0.8-10  sp_1.0-14
  loaded via a namespace (and not attached):
  [1] grid_2.15.3     lattice_0.20-15 tools_2.15.3
  </code></pre>
  
  <p>I used the function from <a href="https://stackoverflow.com/questions/21281148/r-how-to-iterate-over-a-list-preserving-the-format-of-the-results">How to iterate over a list preserving the format of the results?</a> to generate my raster list.</p>
  
  <pre><code>ListRasters &lt;- function(list_names) {
    raster_list &lt;- list() # initialise the list of rasters
     for (i in 1:(length(list_names))){ 
      grd_name &lt;- list_names[i] # list_names contains all the names of the images in .grd format
      raster_file &lt;- raster(grd_name)
     }
    raster_list &lt;- append(raster_list, raster_file) # update raster_list at each iteration
  }
  </code></pre>
  
  <p>Then I generate my list names and create my raster list from them.</p>
  
  <pre><code>wgs84.tif.list &lt;- list.files(path=mod.dir, pattern=glob2rx("*_wgs84.tif"), full.names=T,recursive=F)
  
  list_names &lt;- NULL
  for (i in 1:length(wgs84.tif.list)) {
    list_names &lt;- c(list_names, wgs84.tif.list[i])
  }
  
  raster.list &lt;-sapply(list_names, FUN = ListRasters)
  
  raster.list$fun &lt;- mean
  mos &lt;- do.call(mosaic, raster.list)
  </code></pre>
  
  <p>This is the error I get:</p>
  
  <blockquote>
    <p>Error in function (classes, fdef, mtable) : unable to find an
    inherited method for function 'mosaic' for signature '"missing",
    "missing"'</p>
  </blockquote>
  
  <p>My raster.list starts off like this (it contains 11 rasters):</p>
  
  <pre><code> $`/import/c/w/kbennett/MODSCAG/snow-dav.jpl.nasa.gov/modscag-historic/2002/091/MOD09GA.A2002091.h08v03.005.2007124035032snow_fraction_wgs84.tif`
  class       : RasterLayer
  dimensions  : 2400, 2400, 5760000  (nrow, ncol, ncell)
  resolution  : 463.3127, 463.3127  (x, y)
  extent      : -11119737, -10007786, 5559984, 6671935  (xmin, xmax, ymin, ymax)
  coord. ref. : +proj=sinu +lon_0=0 +x_0=0 +y_0=0 +datum=WGS84 +units=m +no_defs +ellps=WGS84 +towgs84=0,0,0
  data source : /import/c/w/kbennett/MODSCAG/snow-dav.jpl.nasa.gov/modscag-historic/2002/091/MOD09GA.A2002091.h08v03.005.2007124035032snow_fraction_wgs84.tif
  names       : MOD09GA.A2002091.h08v03.005.2007124035032snow_fraction_wgs84
  values      : 0, 255  (min, max)
  </code></pre>