当前位置:网站首页>Gee (III): calculate the correlation coefficient between two bands and the corresponding p value

Gee (III): calculate the correlation coefficient between two bands and the corresponding p value

2022-07-07 23:12:00 BetterQ.

GEE A function for calculating the correlation coefficient is built in , You can analyze the correlation between two variables , For example, we need to analyze the correlation between the two bands , Mainly used ee.Reducer.pearsonsCorrelation() function .

ee.Reducer.pearsonsCorrelation()
Content : Create a dual input reducer , Used to calculate Pearson Product moment correlation coefficient and Correlation = 0 Of 2 edge p Value test .
No input value , Return to Reducer.

To analyze MODIS In the data NDVI and EVI Take the correlation between as an example , The correlation between these two bands will certainly be very high , Here's just an example , The implementation code is as follows :

// This function adds a band representing the image timestamp.
var addTime = function(image) {
    
  return image.addBands(image.metadata('system:time_start')
    // Convert milliseconds from epoch to years to aid in
    // interpretation of the following trend calculation.
    .divide(1000 * 60 * 60 * 24 * 365));
};

// Load a MODIS collection, filter to several years of 16 day mosaics,
// and map the time band function over it.
var collection = ee.ImageCollection('MODIS/006/MYD13A1')
  .filterDate('2004-01-01', '2010-10-31')
  .map(addTime);
 
//correlation between evi and ndvi
var corr1=collection.select('NDVI','EVI')
  .reduce(ee.Reducer.pearsonsCorrelation());
Map.addLayer(
    corr1,
    {
    min: 0, max: 1, bands: ['correlation', 'p-value']},
    'EVI_NDVI correlation');

The main method to calculate the correlation coefficient is var corr1=collection.select('NDVI','EVI') .reduce(ee.Reducer.pearsonsCorrelation());, The output includes correlation coefficient and p value .

原网站

版权声明
本文为[BetterQ.]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/188/202207071956159394.html