MCD19A2 GEE 批量下载每日均值影像

MCD19A2 GEE 批量下载每日均值影像

GEE批量下载图像以MCI9A2为例,以下为参考代码:

//自定义所选区域范围 
var Bounds = 
    ee.Geometry.Polygon(
         [[[50, 55],
          [50, 0],
          [135, 0],
          [135, 55]]], null, false);


//选择数据集
var MAIAC_ImageCollection = ee.ImageCollection('MODIS/006/MCD19A2_GRANULES')
      .filterBounds(Bounds);//区域范围筛选
      // .filterDate("2020-01-01","2020-01-10")//日期筛选
      // .filter(ee.Filter.eq('SATELLITE','A'))//T代表Terra   A 代表 Aqua


//质量筛选
//bitmask质量筛选函数
function bitwiseExtract(value, fromBit, toBit) {
    if (toBit === undefined) toBit = fromBit
    var maskSize = ee.Number(1).add(toBit).subtract(fromBit)
    var mask = ee.Number(1).leftShift(maskSize).subtract(1)
    return value.rightShift(fromBit).bitwiseAnd(mask)
  }

  
// batch函数
var Batch_output_imagecollection = function(Imagecollection) {
  
var QA_MAIAC_ImageCollection = Imagecollection.map(function(img) {
  
  //QA筛选
  var qa = img.select("AOD_QA");//选择QA波段
  var aod550=img.select('Optical_Depth_055').multiply(0.001)//乘以比例因子
  var qamask=bitwiseExtract(qa,8,11).eq(0)//8-11位等于0的也就是 Bits 8-11: QA for AOD  0: Best quality 最好质量的 GEE可以在数据集里查找
  var Best_Aod550=aod550.updateMask(qamask).rename("Best_Aod550")//掩膜提取
  //addband 增加波段
  img=img.addBands(Best_Aod550)
  return img
})

//output_image
var output_image=QA_MAIAC_ImageCollection.select('Best_Aod550').mean()
var startname=ee.DateRange(imagecollection.get('DateRange')).start().format('YYYY_MM_dd', 'GMT')
var endname=ee.DateRange(imagecollection.get('DateRange')).end().format('YYYY_MM_dd', 'GMT')
//导出图像
//可自己更改
Export.image.toDrive({  
       image: output_image,  
       description: 'MAIAC_AOD_MEAN'+startname.getInfo()+'_'+endname.getInfo(),  
       fileNamePrefix: 'MAIAC_AOD_MEAN'+startname.getInfo()+'_'+endname.getInfo(),  //文件命名
       folder: "MAIAC",  //保存的文件夹
       scale: 1000,  //分辨率
       region: Bounds,  //研究区
       maxPixels: 1e13,  //最大像元素
       crs: "EPSG:4326"  //设置投影
   });  
   
// print(output_image)

return output_image
}



//CREAT_ImageCollection 创建数据集
//collection 数据集
//start 开始日期
//count  计数
//interval 时间间隔
//units 单位 day month year
var temporalCollection = function(collection, start, count, interval, units) {
  // Create a sequence of numbers, one for each time interval.
  var sequence = ee.List.sequence(0, ee.Number(count).subtract(1));
  var originalStartDate = ee.Date(start);
  return sequence.map(function(i) {
    // Get the start date of the current sequence.
    var startDate = originalStartDate.advance(ee.Number(interval).multiply(i), units);
    // Get the end date of the current sequence.
    var endDate = originalStartDate.advance(ee.Number(interval).multiply(ee.Number(i).add(1)), units);
    // return collection.filterDate(startDate, endDate)
    var DateRange=ee.DateRange(startDate,endDate)
    return collection.filterDate(DateRange).set('DateRange',DateRange)//设置时间属性
  });
};


//MAIN()
//生成数据集
var days=temporalCollection(MAIAC_ImageCollection,'2020-01-01',5, 1, 'day');
// print(days)

var list_lenth=ee.Number(days.size())
// print(list_lenth)

//测试函数
// var imagecollection=ee.ImageCollection(days.get(0))
// print(imagecollection)
// var result=Batch_output_imagecollection(imagecollection)
// Map.addLayer(result, {min: 0,max: 1,palette: ['black', 'blue', 'purple', 'cyan', 'green', 'yellow', 'red']}, 'Best_Aod550');//添加地图显示


// //bath 批量处理
//i<5(list_lenth)
for(var i=0;i<5;i++){
  imagecollection=ee.ImageCollection(days.get(i))//每日数据
  Batch_output_imagecollection(imagecollection)//
}





由于使用for循环调用函数,GEE批量导出网页可能会卡顿一下为正常情况,并出现任务队列,这里推荐使用Chrom 的一个专门为GEE设置的批量点击插件:
Chrom 的一个专门为GEE设置的批量点击插件
会出现以下图标一键导出图像:
在这里插入图片描述
希望以上能帮助你!

  • 6
    点赞
  • 26
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 11
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 11
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

香橙橙V

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值