如何使用双三次方法在 Google Earth Engine 中对 ImageCollection 重新采样

问题描述 投票:0回答:1

我正在尝试使用双三次方法在 Google Earth Engine 中对 Sentinel 2A ImageCollection 进行重新采样。然而,生成的地图很奇怪。我正在使用以下代码。如果有人帮助我解决这个问题,我很感激:

在下面的代码中,我定义了一个感兴趣区域 (aoi) 和一个函数来获取 aoi 的 Sentinel 2A 图像和特定日期。该函数还对 ImageCollectoin 进行剪辑和马赛克。双三次方法用于对 ImageCollection 进行重新采样。

/**
 * Function to mask clouds using the Sentinel-2 QA band
 * @param {ee.Image} image Sentinel-2 image
 * @return {ee.Image} cloud masked Sentinel-2 image
 */
function maskS2clouds(image) {
  var qa = image.select('QA60');

  // Bits 10 and 11 are clouds and cirrus, respectively.
  var cloudBitMask = 1 << 10;
  var cirrusBitMask = 1 << 11;

  // Both flags should be set to zero, indicating clear conditions.
  var mask = qa.bitwiseAnd(cloudBitMask).eq(0)
      .and(qa.bitwiseAnd(cirrusBitMask).eq(0));

  return image.updateMask(mask).divide(10000);
}

var aoi = 
    /* color: #98ff00 */
    /* displayProperties: [
      {
        "type": "rectangle"
      }
    ] */
    ee.Geometry.Polygon(
        [[[-82.14606816037433, 42.900619674967885],
          [-82.14606816037433, 42.48476153151389],
          [-81.48963505490558, 42.48476153151389],
          [-81.48963505490558, 42.900619674967885]]], null, false);
   
// Show aoi on map
Map.addLayer(aoi, {color: 'yellow'});

// Funcion to clip the sentinel bands
function clipping(im){
   return im.clip(aoi)
}

// Function to get Sentinel 2A images for an aoi and specific date
function getSentinel2WithinDateRange(start,end,aoi){
  var sentinel2 = ee.ImageCollection('COPERNICUS/S2_SR_HARMONIZED')
                    .filterBounds(aoi)
                    .filterDate(start, end)
                    .filter(ee.Filter.lt('CLOUDY_PIXEL_PERCENTAGE', 20))
                    .map(maskS2clouds);
                    
  return sentinel2.map(clipping).mosaic()
}

var date_start = '2024-05-29'
var date_end = '2024-06-30'

var collections = getSentinel2WithinDateRange(date_start, date_end,aoi)
print('Collection info', collections.getInfo())

var visualization = {
  min: 0.0,
  max: 0.3,
  bands: ['B4', 'B3', 'B2'],
};

Map.centerObject(aoi)

Map.addLayer(collections, visualization, 'RGB');

// Resample the collection using bicubic method
var resampled = collections.resample('bicubic')

print ('resample', resampled.getInfo())

var visualization = {
  min: 0.0,
  max: 0.3,
  bands: ['B4', 'B3', 'B2'],
};

// Display the resampled images
Map.addLayer(resampled,visualization);
google-earth-engine sentinel2 resample bicubic
1个回答
0
投票

我在 https://gis.stackexchange.com/ 中发布了问题并得到了解决方案。解决方法请看以下链接:

问题的解决方法

© www.soinside.com 2019 - 2024. All rights reserved.