Reputation: 2651
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!
Upvotes: 0
Views: 1898
Reputation: 4511
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)
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')
plot(cAvg, type='l')
Upvotes: 3