3

I would like to stack all Landsat 8 images from a certain time frame in Google Earth Engine by adding the blue band from each image as a separate band and exporting as a single image.

How would I go about this? I am able to load the collection in, but am unsure what to do next.

// Load Landsat 8 ImageCollection for area.
var collection=ee.ImageCollection('LANDSAT/LC08/C01/T1_TOA')
  .filterDate('2015-01-01','2015-12-31')
  .filterBounds(AOI).select('B2'); 
print('Landsat: ', collection);
  • As far as I know, images are 'stacked' already in var collection, you should be more specific. I recommend first reading developers.google.com/earth-engine – Rodrigo E. Principe Feb 19 '18 at 15:17
  • Thanks for replying - I want to export the stack to my drive. I don't want to undergo any analysis, only to download all imagery for 2015. – TheMinimalistMapper Feb 19 '18 at 15:51
2

If you are using the Code Editor (most likely), you can use a function found here: https://github.com/gee-community/gee_tools/blob/master/js/ExportCol.js. Take in consideration that it will require you to 'Run' every single task manually. It would be something like:

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})
    }
  }

// Load Landsat 8 ImageCollection for area.
var collection=ee.ImageCollection('LANDSAT/LC08/C01/T1_TOA')
  .filterDate('2015-01-01','2015-02-28')
  .filterBounds(AOI).select('B2'); 
print('Landsat: ', collection);

ExportCol(collection, 'CHOOSE_A_FOLDER', 30)

It will download the entire images (all scene), not just the AOI, if you want only the AOI change the las line with:

ExportCol(collection, 'CHOOSE_A_FOLDER', 30, 'float', 500, 1e10, AOI) 

Otherwhise, if you use the Python API you can do it automatically, but the code of course would be different.

  • Thank you Rodrigo, that's exactly what I was looking for – TheMinimalistMapper Feb 19 '18 at 17:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.