Welcome to TERN Knowledge Base

Raster Values: Visualisation

To plot the cell values of a Raster* object, we can use the 'plot' function in the 'raster' package and the 'levelplot' function in the 'rasterVis' package. The later function provides enhanced plots with relative ease.



EXAMPLES


Examples of visualisation of the cell values of rasters (i.e. plotting rasters) in R are presented below. The examples are taken from the “Effects of Cyclone Yasi Green Cover at Mission Beach” tutorial. It can be beneficial to put the code snippets in context by looking at a broader section of the R script. Code snippets have a grey background, and outputs have a white background.


We use the function the ‘levelplot’ function to visualise the raster contents. Before using this function, we create a user defined colour palette; with yellow for low Seasonal Persistent Green Cover (SPGC) values, and green for high values. We use the 'grid.arrange' function in the 'gridExtra' package to plot multiple grobs (i.e. grid graphical objects) on a page (i.e. in a single graph).



Example 1: Plot SPGC Values for both Seasons (winter of 2010 and winter of 2011)

We create the colour palette with colours for values ranging from 0 to 100, as we are plotting percentage values.



Example 2: Plot Raster with Raw & Standardised Differences between both Seasons (winter of 2010 and winter of 2011)

Here creating the colour palette is slightly more elaborated, as we estimate the range of values for the palette from the raster data (i.e. by finding the raster maximum absolute value, see code below).

Provide your feedback about the experience with Knowledge base