cellStats
this function returns a few values, not a Raster* object (see Summary-methods
for that).layerStats(x, stat, w, asSample=TRUE, na.rm=FALSE, ...)
x
) to compute the weighted covarianceTRUE
, the statistic for a sample (denominator is n-1
) is computed, rather than for the population (denominator is n
)cellStats
, cov.wt
, weighted.mean
b <- brick(system.file("external/rlogo.grd", package="raster"))
layerStats(b, 'pearson')
layerStats(b, 'cov')
# weigh by column number
w <- init(b, v='col')
layerStats(b, 'weighted.cov', w=w)
Run the code above in your browser using DataLab