0

how can I tell the spplot function in R to sort the rasters in a different order? Here I have an example with 12 rasters, but I want them in 2 rows and 6 columns instead of 3 rows and 4 columns. I found the grid.arrange function but it doesn't help me because it would plot all rasters including the colour scale. Here is some code to create an example:

library(sp)
library(raster)
r1 <- raster(nrows = 10, ncols = 10, res = 0.5, xmn = -1.5, xmx = 1.5, ymn = -1.5, ymx = 1.5, vals = 0.3)
rr <- lapply(1:12, function(i) setValues(r1,runif(ncell(r1))))
rstack <- stack(rr)
spplot(rstack)

enter image description here

benschbob91
  • 135
  • 11
  • Provide some example dataset so that we can try to solve your problem. Please visit how to make reproducible example in r https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example. – Bappa Das Oct 07 '19 at 04:03

1 Answers1

1

spplot(rstack, layout = c(2,6)) will give you the desired output.

Bappa Das
  • 5,817
  • 3
  • 18
  • 40