Google Earth Engine(GEE)——S2影像异常值

举报
此星光明 发表于 2022/07/15 23:56:56 2022/07/15
【摘要】 在计算索引并生成高质量马赛克时,有一个明显的图像是异常值。我已经确定了图像,问题在于 B5 波段的值非常低,这使得索引具有非常高的值。 编号:哥白尼/S2_SR/20200829T174909_20200829T175522_T13UFP 代码: var imageCollection = ee.ImageCollection...

在计算索引并生成高质量马赛克时,有一个明显的图像是异常值。我已经确定了图像,问题在于 B5 波段的值非常低,这使得索引具有非常高的值。

编号:哥白尼/S2_SR/20200829T174909_20200829T175522_T13UFP

代码:


  
  1. var imageCollection = ee.ImageCollection("COPERNICUS/S2_SR"),
  2. geometry =
  3. /* color: #98ff00 */
  4. /* shown: false */
  5. /* displayProperties: [
  6. {
  7. "type": "rectangle"
  8. }
  9. ] */
  10. ee.Geometry.Polygon(
  11. [[[-103.99506389984352, 48.962358795597474],
  12. [-103.99506389984352, 46.88665586989701],
  13. [-99.68842327484352, 46.88665586989701],
  14. [-99.68842327484352, 48.962358795597474]]], null, false),
  15. geometry2 = /* color: #0b4a8b */ee.Geometry.Point([-102.87049298795543, 48.22935423511586]),
  16. geometry3 = /* color: #00ffff */ee.Geometry.Point([-101.57471425064051, 48.22316284019277]);
  17. //get veg bare soil water
  18. function maskSCL(image) {
  19. var scl = image.select('SCL');
  20. var mask = scl.gte(4).and(scl.lte(6));
  21. return image.updateMask(mask);//.divide(10000);
  22. }
  23. //calculate red edge chlorophyll index
  24. var getIndices = function(img){
  25. var im = img.divide(10000);
  26. var CIre=im.select('B7').divide(im.select('B5')).subtract(1).rename("CIre");
  27. return im.addBands(CIre).copyProperties(img,['system:time_start']);
  28. }
  29. function addDOY(im){
  30. var doy = im.date().getRelative('day', 'year');
  31. var doyBand = ee.Image.constant(doy).uint16().rename('doy')
  32. doyBand = doyBand.updateMask(im.select('B8').mask())
  33. var yr = im.date().get('year')
  34. var yrBand = ee.Image.constant(yr).uint16().rename('year')
  35. yrBand = yrBand.updateMask(im.select('B8').mask())
  36. return im.addBands(doyBand).addBands(yrBand)
  37. }
  38. //max CIre from July-Sept
  39. var dataset1 = imageCollection
  40. .filterBounds(geometry)
  41. .filter(ee.Filter.calendarRange(2018, 2021, 'year'))
  42. .filter(ee.Filter.calendarRange(7, 9, 'month'))
  43. .map(maskSCL)
  44. .map(getIndices)
  45. .map(addDOY)
  46. .select('CIre', 'doy', 'year');
  47. var CIre_max = dataset1.qualityMosaic('CIre');
  48. Map.addLayer(CIre_max.select('CIre'),
  49. {min:0,max:20,palette:['black','indigo','cyan','limegreen','yellow']},'CIre')
  50. Map.addLayer(CIre_max.select('doy'),
  51. {min:183,max:274,palette:['black','indigo','cyan','limegreen','yellow']},'doy')
  52. Map.addLayer(CIre_max.select('year'),
  53. {min:2018,max:2021,palette:['indigo','cyan','limegreen','yellow']},'year')
  54. // var index = dataset1
  55. // .select('CIre')
  56. // .reduce(ee.Reducer.percentile([98]))
  57. // //calculate band to use for quality mosaic of 98th percentile values
  58. // // loop over image collection
  59. // //get absolute difference from 98th percentile
  60. // //convert to 1/abs dif + .1 to use as band for quality mosaic
  61. // var forQM = dataset1.map(function(x){
  62. // // get absolute difference of the percentiles with the CI
  63. // var selector = x.select('CIre').subtract(index).abs();
  64. // var selector_fixed = selector.eq(0).multiply(0.1).add(selector)
  65. // // invert to let the min diff be the largest value
  66. // var invsel = ee.Image.constant(1).divide(selector_fixed);
  67. // // add inverted difference band to the image and name properly
  68. // return x.addBands(invsel.rename('selector_CIre'))
  69. // });
  70. // // // // use the new selectors to perform the quality mosaic and add to map
  71. // var CIre_p98QM = forQM
  72. // .qualityMosaic('selector_CIre')
  73. // .select(['CIre', 'doy'])
  74. // Map.addLayer(CIre_p98QM.select('CIre'),
  75. // {min:0,max:20,palette:['black','indigo','cyan','limegreen','yellow']},'CIre_p98')
  76. // Map.addLayer(CIre_p98QM.select('doy'),
  77. // {min:183,max:274,palette:['black','indigo','cyan','limegreen','yellow']},'doy_p98')
  78. ///print trouble image
  79. //ID COPERNICUS/S2_SR/20200829T174909_20200829T175522_T13UFP
  80. //Think B5 is not right
  81. var checkit = imageCollection
  82. .filterBounds(geometry2)
  83. .filter(ee.Filter.calendarRange(2020, 2020, 'year'))
  84. .filter(ee.Filter.calendarRange(240, 242, 'day_of_year'))
  85. print(checkit)
  86. Map.addLayer(checkit.max(),{bands:['B4','B3','B2'], min:100,max:2000},'trouble_image')
  87. Map.addLayer(checkit.max(),{bands:['B5'], min:100,max:2000},'trouble_b5')
  88. ///nearby image same time period...B5 better
  89. var checkit = imageCollection
  90. .filterBounds(geometry3)
  91. .filter(ee.Filter.calendarRange(2020, 2020, 'year'))
  92. .filter(ee.Filter.calendarRange(240, 242, 'day_of_year'))
  93. print(checkit)
  94. Map.addLayer(checkit.max(),{bands:['B4','B3','B2'], min:100,max:2000},'nearby_image')
  95. Map.addLayer(checkit.max(),{bands:['B5'], min:100,max:2000},'nearby_b5')

 

 

 

 

 

 

文章来源: blog.csdn.net,作者:此星光明,版权归原作者所有,如需转载,请联系作者。

原文链接:blog.csdn.net/qq_31988139/article/details/125689381

【版权声明】本文为华为云社区用户转载文章,如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@huaweicloud.com
  • 点赞
  • 收藏
  • 关注作者

评论(0

0/1000
抱歉,系统识别当前为高风险访问,暂不支持该操作

全部回复

上滑加载中

设置昵称

在此一键设置昵称,即可参与社区互动!

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。