首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >输出图像采集-陆地卫星-8表面温度(谷歌地球引擎)

输出图像采集-陆地卫星-8表面温度(谷歌地球引擎)
EN

Stack Overflow用户
提问于 2022-01-04 10:35:42
回答 1查看 673关注 0票数 0

我一直在努力出口从Landsat-8得到的季度平均表面温度。我无意中发现了“适者生存”的批处理模块。然而,它不是为每个季度导出一个图像,而是输出多个空图像。有人能帮我弄清楚吗?

代码语言:javascript
复制
var batch = require('users/fitoprincipe/geetools:batch');

// This example demonstrates the use of the Landsat 8 Collection 2, Level 2
// QA_PIXEL band (CFMask) to mask unwanted pixels.

function maskL8sr(image) {
  // Bit 0 - Fill
  // Bit 1 - Dilated Cloud
  // Bit 2 - Cirrus
  // Bit 3 - Cloud
  // Bit 4 - Cloud Shadow
  var qaMask = image.select('QA_PIXEL').bitwiseAnd(parseInt('11111', 2)).eq(0).copyProperties(image, ['system:time_start']);
  var saturationMask = image.select('QA_RADSAT').eq(0).copyProperties(image, ['system:time_start']);

  // Apply the scaling factors to the appropriate bands.
  var opticalBands = image.select('SR_B.').multiply(0.0000275).add(-0.2).copyProperties(image, ['system:time_start']);
  var thermalBands = image.select('ST_B.*').multiply(0.00341802).add(-124.15).copyProperties(image, ['system:time_start']);

  // Replace the original bands with the scaled ones and apply the masks.
  return image.addBands(opticalBands, null, true)
      .addBands(thermalBands, null, true)
      .updateMask(qaMask)
      .updateMask(saturationMask)
      .copyProperties(image, ['system:time_start']);
}

// Map the function over one year of data.
var collection = ee.ImageCollection('LANDSAT/LC08/C02/T1_L2')
                     .filterDate('2016-01-01', '2021-12-31')
                     .map(maskL8sr);

// Display the results.
Map.setCenter(120.9854, 14.5994,10);  // Metro Manila
Map.addLayer(composite.select('ST_B10').clip(table), {min: -10, max: 50, palette: 'blue,green,yellow,orange,red'});

var start = ee.Date('2016-01-01');
var end = ee.Date('2021-12-31');
var numbQuarters = end.difference(start, 'month').divide(3).ceil();

// make a composite image for every quarter
var quarterlyImages = ee.ImageCollection.fromImages(
            ee.List.sequence(1, numbQuarters).map(
              function(quarter){
              var startTemp = start.advance(
                              ee.Number(quarter).subtract(1).multiply(3), 'month');
              var endTemp = start.advance(ee.Number(quarter).multiply(3), 'month');
              var image = collection.filterDate(startTemp, endTemp)
                                    .filterBounds(table)
                                    .mean()
                                    .clip(table)
                                    .select('ST_B10');
              return image.set('system:time_start', startTemp.millis(),
                               'system:time_end', endTemp.millis());
            }));
print(quarterlyImages);


batch.Download.ImageCollection.toDrive(quarterlyImages, 'Quarterly Folder', 
                {name: 'LST_{system:index}',
                  scale: 30});

这是代码

EN

回答 1

Stack Overflow用户

发布于 2022-01-04 15:26:59

这是您的工作代码,图像不是空白的。

请选择您感兴趣的区域(此处命名为表),并将其放在//下载图像集合中作为区域: table

这是你的工作代码。

我已将日期从2020-01-01改为2021-12-31,任务显示了8张要上传的图片以供驱动,因为两年将有8个季度。

代码语言:javascript
复制
var batch = require('users/fitoprincipe/geetools:batch');

// This example demonstrates the use of the Landsat 8 Collection 2, Level 2
// QA_PIXEL band (CFMask) to mask unwanted pixels.

function maskL8sr(image) {
  // Bit 0 - Fill
  // Bit 1 - Dilated Cloud
  // Bit 2 - Cirrus
  // Bit 3 - Cloud
  // Bit 4 - Cloud Shadow
  var qaMask = image.select('QA_PIXEL').bitwiseAnd(parseInt('11111', 2)).eq(0).copyProperties(image, ['system:time_start']);
  var saturationMask = image.select('QA_RADSAT').eq(0).copyProperties(image, ['system:time_start']);

  // Apply the scaling factors to the appropriate bands.
  var opticalBands = image.select('SR_B.').multiply(0.0000275).add(-0.2).copyProperties(image, ['system:time_start']);
  var thermalBands = image.select('ST_B.*').multiply(0.00341802).add(-124.15).copyProperties(image, ['system:time_start']);

  // Replace the original bands with the scaled ones and apply the masks.
  return image.addBands(opticalBands, null, true)
      .addBands(thermalBands, null, true)
      .updateMask(qaMask)
      .updateMask(saturationMask)
      .copyProperties(image, ['system:time_start']);
}

// Map the function over one year of data.
var collection = ee.ImageCollection('LANDSAT/LC08/C02/T1_L2')
                     .filterDate('2020-01-01', '2021-12-31')
                     .map(maskL8sr);


// Display the results.
Map.setCenter(120.9854, 14.5994,10);  // Metro Manila


var start = ee.Date('2020-01-01');
var end = ee.Date('2021-12-31');
var numbQuarters = end.difference(start, 'month').divide(3).ceil();

// make a composite image for every quarter
var quarterlyImages = ee.ImageCollection.fromImages(
            ee.List.sequence(1, numbQuarters).map(
              function(quarter){
              var startTemp = start.advance(
                              ee.Number(quarter).subtract(1).multiply(3), 'month');
              var endTemp = start.advance(ee.Number(quarter).multiply(3), 'month');
              var image = collection.filterDate(startTemp, endTemp)
                                    .filterBounds(table)
                                    .mean()
                                    .clip(table)
                                    .select('ST_B10');
              return image.set('system:time_start', startTemp.millis(),
                               'system:time_end', endTemp.millis());
            }));
print(quarterlyImages);

Map.addLayer(quarterlyImages.first(), {min: -10, max: 50, palette: 'blue,green,yellow,orange,red'});

//Download Image Collection 
batch.Download.ImageCollection.toDrive(quarterlyImages, 'Landsat8', {
  name: 'LST_{system:index}',
  type: 'float',
  scale: 30,
  region: table
});
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/70577430

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档