Google Earth Engine – How to Select an Image from ImageCollection

eviexportgoogle-earth-enginegoogle-earth-engine-javascript-apisentinel-2

I'm calculating the EVI of the COPERNICUS/S2 Sentinel-2 dataset on Google Earth Engine. I'm testing exporting my results, and want to view particular images in my processed ImageCollection (called evi2week below). I want to view the second image in evi2week, but don't know how to select it while including all of my EVI calculations instead of the raw COPERNICUS/S2 image. How do I select this second image and all of its bands to add to the map?

//get 2016 dataset
var collection2016= ee.ImageCollection('COPERNICUS/S2')
            .filterBounds(studyarea)
                  .filterDate('2016-01-01', '2016-12-31')
                  // Pre-filter to get less cloudy granules.
                  .filter(ee.Filter.lt('CLOUDY_PIXEL_PERCENTAGE',50));
print('Collection 2016', collection2016);

// make EVI expression into a function
var addEVI=function(image){
var EVI = image.expression(
      '2.5 * ((NIR - RED) / (NIR + 6 * RED - 7.5 * BLUE + 1))', {
      'NIR' : image.select('B8').divide(10000),
      'RED' : image.select('B4').divide(10000),
      'BLUE': image.select('B2').divide(10000)}).rename('EVI');
      return image.addBands(EVI);
};

//map EVI across 2016 dataset
var calculated2016=collection2016.map(addEVI);
print('calculated 2016', calculated2016);

//mapping selecting only EVI band across 2016 dataset
var evi2016 =calculated2016.select('EVI');
print('evi 2016', evi2016);

//making two week period collection to export
var evi2week= evi2016.filterDate('2016-07-01', '2016-07-14');

Best Answer

Quick and dirty way to do this would be to change the image collection to a list of images and then use get() to select the image that you want:

var evi2weekList=ee.ImageCollection(evi2week).toList(999);
var evi2week2ndImage=ee.Image(ee.List(evi2weekList).get(1)); //note index 0 is the first image

print('2ndImage from evi2week imColl',evi2week2ndImage)

Hope that helps :)