GEE exports this I have written before, and the links below are what I wrote before.
Recently, there are many small partners who ask how to export collections in batches. It's too troublesome to reply one by one. Let me just give you an example code here.
var l8 = ee.ImageCollection("LANDSAT/LC08/C01/T1_SR"); var roi = /* color: #d63000 */ee.Geometry.Polygon( [[[115.64960937499995, 39.112756306811285], [116.28681640624995, 39.163883889810315], [116.21540527343745, 39.58850167846649], [115.70454101562495, 39.6054326422912]]]); Map.centerObject(roi, 8); function rmL8Cloud(image) { var cloudShadowBitMask = (1 << 3); var cloudsBitMask = (1 << 5); var qa = image.select('pixel_qa'); var mask = qa.bitwiseAnd(cloudShadowBitMask).eq(0) .and(qa.bitwiseAnd(cloudsBitMask).eq(0)); return image.updateMask(mask); } var l8Imgs = l8.filterBounds(roi) .filterDate("2018-1-1", "2018-3-1") .map(rmL8Cloud); print("l8Imgs", l8Imgs); Map.addLayer(l8Imgs, {min:0, max:3000, bands:["B4","B3","B2"]}, "l8Imgs"); Map.addLayer(roi, {color: "red"}, "roi"); //Image Set Derivation Method 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(roi), description: indexs[i], fileNamePrefix: indexs[i], region: roi, scale: 30, crs: "EPSG:4326", maxPixels: 1e13 }); } }); } exportImageCollection(l8Imgs);
Code analysis:
Let me say a few things to pay attention to here.
(1) The evaluation () method for asynchronous export of data is used here.
(2) There is a sentence in the export code
image = image.toInt16();
The purpose of this sentence is to force the bands of image images to be converted to Int16 data. The reason for this is that the band types of images using the toDrive() method must be identical, which is different from the ones exported to Asset.
(3) The region parameter must be set, and it should be noted that its type is geometry, not feature Collection. If we use a set of vectors, the general approach is:
featureCollection.geometry().bounds() as a parameter of region
(4) maxPixels must be set, because when we export a wide range of images, the default parameter is too small to cause the export failure (default parameter is 1e8).
(5) The crs recommendation is set to EPSG:4326
Operation results:
Derived interface
After exporting to drive
If you have any questions to communicate or projects to cooperate with, you can contact me by Wechat. If you have any friends, please leave a message and add "GEE".
KNOWLEDGE COLUMN: https://zhuanlan.zhihu.com/c_123993183
CSDN: https://blog.csdn.net/shi_weihappy