[R] Combining rasters
Barry Rowlingson
b.rowlingson at lancaster.ac.uk
Fri Sep 6 17:10:28 CEST 2013
[Probably an R-Sig-geo question...]
On Fri, Sep 6, 2013 at 3:57 PM, philippe massicotte
<pmassicotte at hotmail.com> wrote:
> Hi everyone.
>
> I would like to know if it is possible to combine rasters in R to form a "collage".
>
> For example, I would like to place 2 copies of the R logo side by side.
>
>
> r = raster(system.file("external/rlogo.grd", package = "raster"))
Convert to matrix, cbind, convert to raster:
r2 = raster(cbind(as.matrix(r),as.matrix(r)))
plot(r2)
If you want to preserve the x and y scale somehow then you need to
think about exactly where you are putting the second r and set xmx,
ymx xmn, ymn when you construct the new raster.
Barry
More information about the R-help
mailing list