当前位置:   article > 正文

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

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

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

  1. var modis = ee.ImageCollection("MODIS/006/MOD10A1")
  2. .filterDate('2020-1-1', '2020-1-25')
  3. .filterBounds(roi)
  4. .select('NDSI_Snow_Cover')
  5. .map(function(image){
  6. var imgsub = image;
  7. return image.clip(roi)
  8. });
  9. print(modis);
  10. function setSnowCover(image) {
  11. var snowCover = image.select('NDSI_Snow_Cover');
  12. var snowDays = snowCover.neq(0).rename('Snow_Days');
  13. return image.addBands(snowDays);
  14. }
  15. var snowDays = modis.map(setSnowCover);
  16. print(snowDays);
  17. // var snowDaysSum = snowDays.select('Snow_Days').sum().clip(region);
  18. var snowDaysSum = snowDays.select('Snow_Days').sum().clip(roi).toInt();
  19. print(snowDaysSum);
  20. // Map.addLayer(snowDaysSum, {min: 0, max: 30, palette: ['00FF00', 'FF0000']}, 'Snow Days Sum');
  21. Map.centerObject(roi, 6);
  22. var afterFilter = ee.Filter.lessThan({
  23. leftField: 'system:time_start',
  24. rightField: 'system:time_start'
  25. });
  26. var joined = ee.ImageCollection(ee.Join.saveAll('after').apply({
  27. primary: modis,
  28. secondary: modis,
  29. condition: afterFilter
  30. })).aside(print);
  31. var sign = function(i, j) { // i and j are images
  32. return ee.Image(j).neq(i) // Zero case
  33. .multiply(ee.Image(j).subtract(i).clamp(-1, 1)).int();
  34. };
  35. var kendall = ee.ImageCollection(joined.map(function(current) {
  36. var afterCollection = ee.ImageCollection.fromImages(current.get('after'));
  37. return afterCollection.map(function(image) {
  38. // The unmask is to prevent accumulation of masked pixels that
  39. // result from the undefined case of when either current or image
  40. // is masked. It won't affect the sum, since it's unmasked to zero.
  41. return ee.Image(sign(current, image));
  42. });
  43. // Set parallelScale to avoid User memory limit exceeded.
  44. }).flatten()).sum();
  45. print(kendall);
  46. var palette = ['red', 'yellow', 'green'];
  47. // 归一化Kendall系数到-1到1的范围
  48. var normalizedKendall = kendall.divide(100);
  49. Map.addLayer(normalizedKendall, {min: -1, max: 1, palette: palette}, 'Normalized Kendall Trend');
  50. Export.image.toDrive({
  51. image: kendall,
  52. folder: 'MK_export',
  53. scale: 500,
  54. region: roi,
  55. maxPixels: 1e13
  56. });

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/Gausst松鼠会/article/detail/592320
推荐阅读
相关标签
  

闽ICP备14008679号