This GEE documentation addressed the correlation chart of two bands over a region.

// Define an arbitrary region of interest.
var sanFrancisco = ee.Geometry.Rectangle([-122.45, 37.74, -122.4, 37.8]);

// Load a Landsat 8 image.
var image = ee.Image('LANDSAT/LC08/C01/T1_TOA/LC08_044034_20140318');

// Get a dictionary with band names as keys, pixel lists as values.
var result = image.reduceRegion(ee.Reducer.toList(), sanFrancisco, 120);

// Convert the band data to plot on the y-axis to arrays.
var y1 = ee.Array(result.get('B5'));
var y2 = ee.Array(result.get('B6'));
// Concatenate the y-axis data by stacking the arrays on the 1-axis.
var yValues = ee.Array.cat([y1, y2], 1);

// The band data to plot on the x-axis is a List.
var xValues = result.get('B4');

// Make a band correlation chart.
var chart = ui.Chart.array.values(yValues, 0, xValues)
    .setSeriesNames(['B5', 'B6'])
      title: 'LC8 TOA B4 vs. {B5,B6}',
      hAxis: {'title': 'B4'},
      vAxis: {'title': '{B5,B6}'},
      pointSize: 3,

// Print the chart.

My question is how to get the value of their correlation? For example how to apply the ee.Reducer.pearsonsCorrelation() in this case?


for instance we have an Image collection of landsat 8, pearson correlation test between Band1 and Band2:

  imageCollection: imageCollection.select(['B1','B2']),
  region: geometry,
  reducer: ee.Reducer.pearsonsCorrelation(),
  scale: 30})
var geometry = /* color: #d63000 */ee.Geometry.Polygon(
    [[[-122.49306916503907, 37.77346675833223],
      [-122.48997926025392, 37.738722521119186],
      [-122.41101502685548, 37.747953050546485],
      [-122.41822480468751, 37.7886622307073]]]);
// Load a Landsat 8 collection for a single path-row.
var collection = ee.ImageCollection('LANDSAT/LC08/C01/T1_TOA')
  .filter(ee.Filter.eq('WRS_PATH', 44))
  .filter(ee.Filter.eq('WRS_ROW', 34))
  .filterDate('2014-01-01', '2020-01-01');
// Compute a median image and display.
var median = collection.median();
Map.setCenter(-122.3578, 37.7726, 12);
Map.addLayer(median, {bands: ['B4', 'B3', 'B2'], max: 0.3}, 'median');

// Make a band correlation chart.
  imageCollection: collection.select(['B1','B10']),
  region: geometry,
  reducer: ee.Reducer.pearsonsCorrelation(),
  scale: 30}));


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.