[R-sig-Geo] Mosaic Rasters

Robert J. Hijmans r.hijmans at gmail.com
Mon Sep 22 12:50:09 CEST 2014


Brian,

What you can do in a situation like this (clearly a bug; difficult to
reproduce) is with your list "x":

y <- sapply(x, raster) # remove all valus
save(y, file='mosaic.RData')

and send the file (and explanation of how you get the error) to the
package maintainer (i.e., me, in this case).

Best, Robert

On Fri, Sep 19, 2014 at 5:37 PM, Brian Buma <brian.buma at uas.alaska.edu> wrote:
> I apologize I don't have reproduce-able code, but I don't entirely
> understand the error.
>
> I have a list of rasters which are all subsets of the same watershed,
> created from a lidar dataset.  Because of memory limitations, I had to
> process in chunks, and now I'm mosaicing them back together.  The code is a
> quick for loop, and it loads one, mosaics it to the previous one, and then
> moves onto the next one.
>
> However, sometimes I get an error of "Error in v[cells, i] <-
> getValues(x[[i]]) :
>   number of items to replace is not a multiple of replacement length"
>
> I understand what that means in terms of vectors and things, but I don't
> get it for the raster.  I thought perhaps it was because each chunk wasn't
> exactly the same size in terms of rows and columns (all are the same
> resolution).  But if I skip the chunks that kick out that error, then go
> back and mosaic them at the end, it works.  So with careful ordering of my
> input chunks, I can get the whole mosaic out.  Why would that be?
>  Shouldn't mosaic be able to handle all sorts of various extents, assuming
> the projection, resolution, and origin are the same?  Maybe that's not the
> problem?
>
> Again, apologize for not having more info to go on, but I don't really know
> what is going wrong so I can't recreate the error in a code snippet.
>
> -brian
>
>         [[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo



More information about the R-sig-Geo mailing list