Google Earth Engine – Mapping Expressions Over Sentinel-2 Dataset with Google Earth Engine

evigoogle-earth-enginegoogle-earth-engine-javascript-apisentinel-2

I'm using Google Earth Engine to map an expression over a Sentinel-2 dataset. I want to calculate the EVI for an entire year of a particular area. My code is:

/// Add EVI using an expression.
//Make EVI calculation an expression
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);
};

//Apply EVI calculation to 2016 dataset
var eviof2016= ee.ImageCollection('COPERNICUS/S2_SR')
            //.filterBounds(studyarea)
                  .filterDate('2016-01-01', '2016-12-31')
                  // Pre-filter to get less cloudy granules.
                  .filter(ee.Filter.lt('CLOUDY_PIXEL_PERCENTAGE',50))
                  .map(addEVI);
print(eviof2016);

I've muted //.filterBounds(studyarea) here because the geometry relies on an uploaded shapefile, and I wanted this code to have the ability to run for anyone.

When I run this code, I do get something in the console, but it says

ImageCollection COPERNICUS/S2_SR (0 elements)

type:ImageCollection

id: COPERNICUS/S2_SR

version: 1638537090781682

bands: []

features: []

properties: Object (21 properties)

date_range: [1490659200000,1638403200000]

description: (…)

keywords: List (7 elements)

period: 0

product_tags: ["msi","sr","reflectance"]

provider: European Union/ESA/Copernicus

provider_url:
https://earth.esa.int/web/sentinel/user-guides/sentinel-2-msi/

sample:
https://mw1.google.com/ges/dd/images/COPERNICUS_S2_SR_sample.png

source_tags: ["eu","esa","copernicus","sentinel"]

system:visualization_0_bands: B4,B3,B2

system:visualization_0_max: 3000.0

system:visualization_0_min: 0.0

system:visualization_0_name: RGB

tags: List (7 elements)

thumb: https://mw1.google.com/ges/dd/images/COPERNICUS_S2_SR_thumb.png

title: Sentinel-2 MSI: MultiSpectral Instrument, Level-2A

type_name: ImageCollection

visualization_0_bands: B4,B3,B2

visualization_0_max: 3000.0

visualization_0_min: 0.0

visualization_0_name: RGB

Please note that under description, there was an extensive description of the COPERNICUS/S2_SR dataset, and that I elected not to show it due to its length.

Why does it print this output instead of a collection of images?

How do I properly map my band math expression across the dataset?

Best Answer

Sentinel-2 Level-2A has the following specification:

Dataset Availability 2017-03-28T00:00:00 -

Although Sentinel-2 Level-1C is available since mid-2015, the atmospherically corrected product is only available in GGE from 2017 data.

Sadly, the workaround for this issue is to download L1C products and use Sen2cor for getting L2A scenes (or apply EVI to L1C products, it depends on your needs).