I need to download a bunch of Landsat images for my thesis. My problem seems simple but I don\'t have a clue about JavaScript and the documentation didn\'t help enough. I ha
I have created a function to perform a similar action. It is available in a bunch of gee tools I've created: https://github.com/fitoprincipe/geetools-code-editor
Here is the code:
/*
* Author: Rodrigo E. Principe
* License: Apache 2.0
PURPOSE:
This function Exports all images from one Collection
PARAMETERS:
col = collection that contains the images (ImageCollection) (not optional)
folder = the folder where images will go (str) (not optional)
scale = the pixel's scale (int) (optional) (defaults to 1000) (for Landsat use 30)
type = data type of the exported image (str) (option: "float", "byte", "int", "double") (optional) (defaults to "float")
nimg = number of images of the collection (can be greater than the actual number) (int) (optional) (defaults to 500)
maxPixels = max number of pixels to include in the image (int) (optional) (defults to 1e10)
region = the region where images are on (Geometry.LinearRing or Geometry.Polygon) (optional) (defaults to the image footprint)
Be careful with the region parameter. If the collection has images
in different regions I suggest not to set that parameter
EXAMPLE:
ExportCol(myLandsatCol, "Landsat_imgs", 30)
*/
var ExportCol = function(col, folder, scale, type,
nimg, maxPixels, region) {
type = type || "float";
nimg = nimg || 500;
scale = scale || 1000;
maxPixels = maxPixels || 1e10;
var colList = col.toList(nimg);
var n = colList.size().getInfo();
for (var i = 0; i < n; i++) {
var img = ee.Image(colList.get(i));
var id = img.id().getInfo();
region = region || img.geometry().bounds().getInfo()["coordinates"];
var imgtype = {"float":img.toFloat(),
"byte":img.toByte(),
"int":img.toInt(),
"double":img.toDouble()
}
Export.image.toDrive({
image:imgtype[type],
description: id,
folder: folder,
fileNamePrefix: id,
region: region,
scale: scale,
maxPixels: maxPixels})
}
}
I haven't tried it a lot, but worked in a couple of test I made, example:
var batch = require('users/fitoprincipe/geetools:batch')
var col = ee.ImageCollection("LEDAPS/LE7_L1T_SR").filterDate("2002-01-01","2002-01-03");
batch.Download.ImageCollection.toDrive(col, "Folder", {scale:30});
If you have any issue you can comment here, but also you can post it on github.