
Last chance! 50% off unlimited learning
Sale ends in
Calculate the Pearson correlation coefficient matrix for a rasterstack
pearson_correlation_matrix(x, cachesize = 20, same_mask = FALSE)
A correlation matrix.
RasterStack. The stack of rasters you want to calculate the Pearson
correlation coefficient matrix for. This can be obtained by calling
load_layers
.
integer. For how many rasters should the values be kept in local memory. By default this is set to 20, a parameter which works reasonably well on a windows computer with 8GB RAM.
logical. Whether we can assume that the mask is the same
for all layers (same NA values), default is FALSE
.
layers_correlation plot_correlation
load_layers
if (FALSE) {
# calculate correlation between SST and salinity in the Baltic Sea
# warning using tempdir() implies that data will be downloaded again in the
# next R session
x <- load_layers(c("BO_sstmax", "BO_salinity"), datadir = tempdir())
e <- extent(13, 31, 52, 66)
baltics <- crop(x, e)
print(pearson_correlation_matrix(baltics))
}
Run the code above in your browser using DataLab