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

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

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

编号:哥白尼/S2_SR/20200829T174909_20200829T175522_T13UFP

代码:

var imageCollection = ee.ImageCollection("COPERNICUS/S2_SR"),
    geometry = 
    /* color: #98ff00 */
    /* shown: false */
    /* displayProperties: [
      {
        "type": "rectangle"
      }
    ] */
    ee.Geometry.Polygon(
        [[[-103.99506389984352, 48.962358795597474],
          [-103.99506389984352, 46.88665586989701],
          [-99.68842327484352, 46.88665586989701],
          [-99.68842327484352, 48.962358795597474]]], null, false),
    geometry2 = /* color: #0b4a8b */ee.Geometry.Point([-102.87049298795543, 48.22935423511586]),
    geometry3 = /* color: #00ffff */ee.Geometry.Point([-101.57471425064051, 48.22316284019277]);
//get veg bare soil water
function maskSCL(image) {
  var scl = image.select('SCL');
  var mask = scl.gte(4).and(scl.lte(6));
  return image.updateMask(mask);//.divide(10000);
}
//calculate red edge chlorophyll index
var getIndices = function(img){
  var im = img.divide(10000);
  var CIre=im.select('B7').divide(im.select('B5')).subtract(1).rename("CIre");
  return im.addBands(CIre).copyProperties(img,['system:time_start']);
}
function addDOY(im){
  var doy = im.date().getRelative('day', 'year');
  var doyBand = ee.Image.constant(doy).uint16().rename('doy')
  doyBand = doyBand.updateMask(im.select('B8').mask())
  var yr = im.date().get('year')
  var yrBand = ee.Image.constant(yr).uint16().rename('year')
  yrBand = yrBand.updateMask(im.select('B8').mask())
  return im.addBands(doyBand).addBands(yrBand)
}
//max CIre from July-Sept
var dataset1 = imageCollection
.filterBounds(geometry)
.filter(ee.Filter.calendarRange(2018, 2021, 'year'))
.filter(ee.Filter.calendarRange(7, 9, 'month'))
.map(maskSCL)
.map(getIndices)
.map(addDOY)
.select('CIre', 'doy', 'year');
var CIre_max = dataset1.qualityMosaic('CIre');
Map.addLayer(CIre_max.select('CIre'),
{min:0,max:20,palette:['black','indigo','cyan','limegreen','yellow']},'CIre')
Map.addLayer(CIre_max.select('doy'),
{min:183,max:274,palette:['black','indigo','cyan','limegreen','yellow']},'doy')
Map.addLayer(CIre_max.select('year'),
{min:2018,max:2021,palette:['indigo','cyan','limegreen','yellow']},'year')
// var index = dataset1
// .select('CIre')
// .reduce(ee.Reducer.percentile([98]))
// //calculate band to use for quality mosaic of 98th percentile values
// // loop over image collection
// //get absolute difference from 98th percentile
// //convert to 1/abs dif + .1 to use as band for quality mosaic
// var forQM  = dataset1.map(function(x){             
//   // get absolute difference of the percentiles with the CI
//   var selector = x.select('CIre').subtract(index).abs();
//   var selector_fixed = selector.eq(0).multiply(0.1).add(selector)
//   // invert to let the min diff be the largest value
//   var invsel   = ee.Image.constant(1).divide(selector_fixed);
//   // add inverted difference band to the image and name properly
//   return x.addBands(invsel.rename('selector_CIre'))   
// });
// // // // use the new selectors to perform the quality mosaic and add to map
// var CIre_p98QM  = forQM
// .qualityMosaic('selector_CIre')
// .select(['CIre', 'doy'])
// Map.addLayer(CIre_p98QM.select('CIre'),
// {min:0,max:20,palette:['black','indigo','cyan','limegreen','yellow']},'CIre_p98')
// Map.addLayer(CIre_p98QM.select('doy'),
// {min:183,max:274,palette:['black','indigo','cyan','limegreen','yellow']},'doy_p98')
///print trouble image
//ID COPERNICUS/S2_SR/20200829T174909_20200829T175522_T13UFP
//Think B5 is not right
var checkit = imageCollection
.filterBounds(geometry2)
.filter(ee.Filter.calendarRange(2020, 2020, 'year'))
.filter(ee.Filter.calendarRange(240, 242, 'day_of_year'))
print(checkit)
Map.addLayer(checkit.max(),{bands:['B4','B3','B2'], min:100,max:2000},'trouble_image')
Map.addLayer(checkit.max(),{bands:['B5'], min:100,max:2000},'trouble_b5')
///nearby image same time period...B5 better
var checkit = imageCollection
.filterBounds(geometry3)
.filter(ee.Filter.calendarRange(2020, 2020, 'year'))
.filter(ee.Filter.calendarRange(240, 242, 'day_of_year'))
print(checkit)
Map.addLayer(checkit.max(),{bands:['B4','B3','B2'], min:100,max:2000},'nearby_image')
Map.addLayer(checkit.max(),{bands:['B5'], min:100,max:2000},'nearby_b5')

image.png

image.png

image.png

image.pngimage.pngimage.png


相关文章
|
1天前
|
数据可视化 定位技术 Sentinel
如何用Google Earth Engine快速、大量下载遥感影像数据?
【2月更文挑战第9天】本文介绍在谷歌地球引擎(Google Earth Engine,GEE)中,批量下载指定时间范围、空间范围的遥感影像数据(包括Landsat、Sentinel等)的方法~
684 0
如何用Google Earth Engine快速、大量下载遥感影像数据?
|
1天前
|
机器学习/深度学习 算法 数据可视化
基于Google Earth Engine云平台构建的多源遥感数据森林地上生物量AGB估算模型含生物量模型应用APP
基于Google Earth Engine云平台构建的多源遥感数据森林地上生物量AGB估算模型含生物量模型应用APP
112 0
|
1天前
|
存储 编解码 数据可视化
Google Earth Engine获取随机抽样点并均匀分布在栅格的不同数值区中
【2月更文挑战第14天】本文介绍在谷歌地球引擎(Google Earth Engine,GEE)中,按照给定的地表分类数据,对每一种不同的地物类型,分别加以全球范围内随机抽样点自动批量选取的方法~
274 0
Google Earth Engine获取随机抽样点并均匀分布在栅格的不同数值区中
|
1天前
|
API Go 网络架构
GEE Colab——如何从本地/Google云盘/Google Cloud Storage (GCS)上传和下载
GEE Colab——如何从本地/Google云盘/Google Cloud Storage (GCS)上传和下载
102 4
|
1天前
|
机器学习/深度学习 存储 人工智能
GEE Colab——初学者福音快速入门 Google Colab(Colaboratory)
GEE Colab——初学者福音快速入门 Google Colab(Colaboratory)
82 3
|
1天前
|
编解码 人工智能 算法
Google Earth Engine——促进森林温室气体报告的全球时间序列数据集
Google Earth Engine——促进森林温室气体报告的全球时间序列数据集
33 0
|
1天前
|
编解码 人工智能 数据库
Google Earth Engine(GEE)——全球道路盘查项目全球道路数据库
Google Earth Engine(GEE)——全球道路盘查项目全球道路数据库
48 0
|
1天前
|
编解码
Open Google Earth Engine(OEEL)——matrixUnit(...)中产生常量影像
Open Google Earth Engine(OEEL)——matrixUnit(...)中产生常量影像
23 0
|
1天前
Google Earth Engine(GEE)——导出指定区域的河流和流域范围
Google Earth Engine(GEE)——导出指定区域的河流和流域范围
53 0
|
1天前
|
传感器 编解码 数据处理
Open Google Earth Engine(OEEL)——哨兵1号数据的黑边去除功能附链接和代码
Open Google Earth Engine(OEEL)——哨兵1号数据的黑边去除功能附链接和代码
26 0

热门文章

最新文章