0

I've been trying to compute Pearson's Correlation in GEE, I have 2 raster images stored as assets. The code runs just find but the output is empty. Please help me with the code. https://code.earthengine.google.com/dc46325f63b16f13c0f10f606f75768d

Map.centerObject(image)
Map.addLayer(image)
Map.addLayer(image2)
// Load the two rasters as image objects'
var raster1 = image;
print(image)
var raster2 = image2;

// Create an image collection containing the two rasters
var imageCollection = raster1.addBands(raster2)
print(imageCollection)

var correlate =ee.ImageCollection(imageCollection);
print(correlate)

var correlationCol = correlate.select(['b1', 'b1_1'])


// Calculate Pearson's correlation between the two rasters
var correlation = correlationCol.reduce(ee.Reducer.pearsonsCorrelation());

// Print the correlation coefficient
print("Pearson's correlation coefficient: ", correlation);

var positive = correlation.select('correlation').gt(0.5)

Map.addLayer(correlation.select('correlation'), 
  {min:-1, max:1, palette: ['red', 'white', 'green']}, 'Correlation');
Map.addLayer(positive, 
  {palette: ['yellow']}, 'Positive Correlation', false);

Tried making a collection but it didn't work

type here

0 Answers0