GEE学习笔记 二十:Export简单介绍

日期:

如何导出GEE的资源是非常中重要的一个问题,在GEE官方文档中已经有非常详细的导出代码,下面举个例子:

//导出单张影像到Drive中
var landsat = ee.Image('LANDSAT/LC8_L1T_TOA/LC81230322014135LGN00')
 .select(['B4', 'B3', 'B2']);
var geometry = ee.Geometry.Rectangle([116.2621, 39.8412, 116.4849, 40.01236]);
Map.centerObject(geometry, 7);
Map.addLayer(geometry, {}, "geometry");

// To Drive
Export.image.toDrive({
 image: landsat,
 description: 'imageToDriveExample',
 scale: 30,
 region: geometry
});

 

那么如何导出多张影像到Drive中,直接上代码

//export collection 导出imageCollection
var collection = ee.ImageCollection('LANDSAT/LC8_L1T_TOA')
       .filter(ee.Filter.eq('WRS_PATH', 44))
       .filter(ee.Filter.eq('WRS_ROW', 34))
       .filterDate('2015-01-01', '2015-04-01');
print('Collection: ', collection);
var colList = collection.toList(100);
//这里需要注意的是获取长度使用的是getInfo(),直接通过size()是不可以的
var n = colList.size().getInfo();
print("n is: ", n);
for (var i = 0; i < n; i++) {
 var img = ee.Image(colList.get(i));
 var id = img.id();
 print("id is: ", id);
 var bounds = img.geometry().bounds();
 print("bounds is: ", bounds);
 // var region = bounds.coordinates;


 Export.image.toDrive({
   image:img.toFloat(),
   description: "L8_Export:"+id.getInfo(),
   region: bounds,
   scale: 30,
   maxPixels: 999999999999});
}

 

输出结果:

 

导出任务界面