Sen+Mann-Kendall(MK)趋势检验(积雪数据集)

Mann-Kendall 趋势定义为所有正的符号之和。如果后一天的积雪大于前一天的积雪,则符号为 1,如果相反,则符号为 -1,否则为零。通过迭代集合中的每个图像。

var modis = ee.ImageCollection("MODIS/006/MOD10A1")
                        .filterDate('2020-1-1', '2020-1-25')
                        .filterBounds(roi)
                        .select('NDSI_Snow_Cover')
                        .map(function(image){
                          var imgsub = image;
                          return image.clip(roi)
                        });
print(modis);
function setSnowCover(image) {
  var snowCover = image.select('NDSI_Snow_Cover');
  var snowDays = snowCover.neq(0).rename('Snow_Days');
  return image.addBands(snowDays);
}
var snowDays = modis.map(setSnowCover);
print(snowDays);
// var snowDaysSum = snowDays.select('Snow_Days').sum().clip(region);
var snowDaysSum = snowDays.select('Snow_Days').sum().clip(roi).toInt();
print(snowDaysSum);
// Map.addLayer(snowDaysSum, {min: 0, max: 30, palette: ['00FF00', 'FF0000']}, 'Snow Days Sum');
Map.centerObject(roi, 6);

var afterFilter = ee.Filter.lessThan({
  leftField: 'system:time_start',
  rightField: 'system:time_start'
});

var joined = ee.ImageCollection(ee.Join.saveAll('after').apply({
  primary: modis,
  secondary: modis,
  condition: afterFilter
})).aside(print);
var sign = function(i, j) { // i and j are images
  return ee.Image(j).neq(i) // Zero case
      .multiply(ee.Image(j).subtract(i).clamp(-1, 1)).int();
};

var kendall = ee.ImageCollection(joined.map(function(current) {
  var afterCollection = ee.ImageCollection.fromImages(current.get('after'));
  return afterCollection.map(function(image) {
    // The unmask is to prevent accumulation of masked pixels that
    // result from the undefined case of when either current or image
    // is masked.  It won't affect the sum, since it's unmasked to zero.
    return ee.Image(sign(current, image));
  });
  // Set parallelScale to avoid User memory limit exceeded.
}).flatten()).sum();
print(kendall);
var palette = ['red', 'yellow', 'green'];
// 归一化Kendall系数到-1到1的范围
var normalizedKendall = kendall.divide(100); 
Map.addLayer(normalizedKendall, {min: -1, max: 1, palette: palette}, 'Normalized Kendall Trend');
  Export.image.toDrive({
    image: kendall,
    folder: 'MK_export',
    scale: 500, 
    region: roi,
    maxPixels: 1e13
  });

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值