Search code examples
rrasterboxplotr-raster

Multiple Raster Boxplots in R


I am trying to make a figure that has a boxplot for 14 different rasters. Each raster represents the snow depth surface for a given 100m elevation band, from 1300-2600 masl. I know how to make a boxplot for each raster individually, but cannot figure out how to get all 14 onto the same figure. It would be ideal to skip converting the rasters to ASCII grids as has been previously suggested to me. Any help is much appreciated!


Solution

  • You can do

    r1 = raster(vals=rnorm(100,2), ncols=10, nrows=10)
    r2 = raster(vals=rnorm(100,5,2), ncols=10, nrows=10)
    r3 = raster(vals=rnorm(100,4), ncols=10, nrows=10)
    boxplot(data.frame(r1=values(r1), r2=values(r2), r3=values(r3)))
    

    enter image description here