문제

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!

도움이 되었습니까?

해결책

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top