Google earth engine批量下载MODIS数据并导出

下载MODIS数据的时候,有时候只是需要研究区一个小范围的数据,但是直接在官网下载还需要下载对应范围所在的分幅数据,这个量或许比较大,感觉比较麻烦

因此这里记录一下利用GEE批量下载的过程(PS:还是有个稳定的VPN比较好啊 从谷歌云盘把数据下载下来)

准备:

研究区矢量边界shp文件

明确要下载的MODIS数据

var fc = ee.FeatureCollection(“users/test/Qinling”)//研究区矢量
Map.centerObject(fc,4)
print(imageCollection)
var collection = ee.ImageCollection('MODIS/006/MOD11A2').filterDate('2000-01-01', '2021-03-11').select(1).filterBounds(fc)
print(collection)
function exportImageCollection(imgCol) { 
  var indexList = imgCol.reduceColumns(ee.Reducer.toList(), ["system:index"]) 
                        .get("list"); 
  indexList.evaluate(function(indexs) { 
    for (var i=0; i<indexs.length; i++) { 
      var image = imgCol.filter(ee.Filter.eq("system:index", indexs[i])).first(); 
      image = image.toInt16(); 
      Export.image.toDrive({ 
        image: image.clip(fc.geometry().bounds()), 
        description: indexs[i], 
        fileNamePrefix: indexs[i], 
        region: fc.geometry().bounds(), 
        scale: 500, 
        crs: "EPSG:4326",   
        folder: "LST",//谷歌云盘中的文件夹名称
        maxPixels: 1e13 
      }); 
    } 
  }); 
} 
exportImageCollection(collection);

//COLLECTION导出 备选尝试方案
batch.Download.ImageCollection.toDrive(collection,"result", {
scale: 30,
region: roi,                //研究区域
maxPixels:34e10,            //此处值设置大一些,防止溢出
type:"int16" })

 

 

注意:

image = image.toInt16(); 这句话的作用是将image影像的波段都强制转为Int16类型数据,这么做的原因是使用toDrive()方法影像的波段类型必须是一致的,这点和导出到Asset不太一样

region参数必须要设置,同时需要注意的是它的类型是geometry,不是featureCollection。如果我们用的是矢量集合,那么一般做法是:

featureCollection.geometry().bounds()作为region的参数  或者table.union().geometry() 还没有试过

maxPixels必须设置,因为我们在导出大范围的影像时候会出现默认参数过小导致导出失败(默认参数是1e8)

crs推荐设置为EPSG:4326

关于投影与重采样问题:

 https://blog.csdn.net/weixin_29876887/article/details/112708491

这时候会发现数量很多的话需要点很多下run按钮

因此F12(谷歌浏览器),在控制台中输入以下代码:

function runTaskList() {
    var tasklist = document.getElementsByClassName('awaiting-user-config');
    for (var i = 0; i < tasklist.length; i++)
        tasklist[i].children[2].click();
}
function confirmAll() {
    var ok = document.getElementsByClassName('goog-buttonset-default goog-buttonset-action');
    for (var i = 0; i < ok.length; i++)
        ok[i].click();
}
runTaskList();
confirmAll();

 

 

参考:

https://www.seibert.cn/blog/38 

https://blog.csdn.net/shi_weihappy/article/details/100142417

https://blog.csdn.net/weixin_40450867/article/details/104578379

https://blog.csdn.net/weixin_40450867/article/details/104578379

 

posted @ 2021-03-13 16:44  icydengyw  阅读(2197)  评论(0编辑  收藏  举报