GEE(3):计算两个波段间的相关系数与相应的p值

您所在的位置:网站首页 pearson相关性r值与p值excel GEE(3):计算两个波段间的相关系数与相应的p值

GEE(3):计算两个波段间的相关系数与相应的p值

2024-03-31 17:02| 来源: 网络整理| 查看: 265

GEE中内置了计算相关系数的函数,可以分析两个变量之间的相关性,比如要分析两个波段之间的相关性,主要用到ee.Reducer.pearsonsCorrelation()函数。

ee.Reducer.pearsonsCorrelation() 内容:创建一个双输入归约器,用于计算 Pearson 的积矩相关系数和相关性 = 0 的 2 边 p 值检验。 无输入值,返回为Reducer.

以分析MODIS数据中NDVI和EVI之间的相关性为例,这两个波段的相关性肯定会很高,这里只是做个示例,实现代码如下:

// 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');

计算相关系数的主要为var corr1=collection.select('NDVI','EVI') .reduce(ee.Reducer.pearsonsCorrelation());,输出包括相关系数和p值。



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3