Sunday, 3 June 2018

How to stack bands in Google Earth Engine?


I have created an Image collection in GEE and with the help of a function I have computed NDVI index and mapped it to create another collection with NDVI as a band.


Now I want the create a stacked image with NDVI bands of the entire image collection into one image. So it should be like NDVI_1, NDVI_2 and so on...



How can I do this? I am pasting the code that shows the NDVI collection that I have so far


// Collection of Images 
var collection = ee.ImageCollection([feb1,feb2,Mar2,April1, April2, May1, May2, Jun1,Jun2,
July2, Aug2, Sep1, Sep2,Oct1, Oct2, Nov1, Nov2, Dec1, Dec2 ]);



//Using the following function,NDVI of the entire collection is computed
var indicesS2 = function(scene)
{ var ndvi = scene.normalizedDifference(['B8', 'B4']).rename('NDVI');

var image = ee.Image()
.set('system:time_start', ee.Date(scene.get('system:time_start')));
return image.addBands([ndvi]).clip(Sheikhupura);
};
var NDVIcollection = collection.map(indicesS2);
print (NDVIcollection, 'NDVI');

Answer



Note that the new, better way to do this is with imageCollection.toBands().


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...