In levelplot (RasterVis), what by default does the graph show on each axis?

1.8k views Asked by At

I'm using the levelplot function in the RasterVis package to plot one raster. I use the following code on my GeoTiff:

require(raster)
require(rasterVis)
data <- raster("mytiff.tif")
levelplot(data, layers=1, par.settings=RdBuTheme)

What, by default, do the graphs presented in the margins show? Is it the mean for each column/row or the median or a cumulative count or something else?

I can't find this in the help information, so any enlightenment would be much appreciated.

Thanks!

1

There are 1 answers

2
Oscar Perpiñán On BEST ANSWER

These graphics are the row and column summaries of the RasterLayer. The summary is computed with the function defined by FUN.margin (which uses mean as default value).

Let's illustrate it with an example:

library(raster)
library(rasterVis)

f <- system.file("external/test.grd", package="raster")
r <- raster(f)

levelplot(r)

levelplot

The graphics shown in the margins can be produced with the zonal function. With init we create two RasterLayer with the rows and cols numbers to define the zones to be summarized.

rows <- init(r, v='row')
cols <- init(r, v='col')

rAvg <- zonal(r, rows, fun='mean')
cAvg <- zonal(r, cols, fun='mean')

The result is the same:

plot(rAvg, type='l')

row average

plot(cAvg, type='l')

column average