TransWikia.com

Pattern did not match any band error for Sentinel 2, 2015 year image in Google Earth Engine

Geographic Information Systems Asked by Arushi on November 17, 2020

I am trying to calculate MNDWI index for Sentinel 2 image of an area for 2015 year data in Google Earth Engine.

var image2 = ee.ImageCollection('COPERNICUS/S2')
                  .filterDate('2015-06-23', '2015-12-31')
                  // Pre-filtering to get less cloudy granules.
                  .filter(ee.Filter.lt('CLOUDY_PIXEL_PERCENTAGE', 20))
                  .filterBounds(point)
                  .select(['B3', 'B11'])
                  .reduce(ee.Reducer.percentile([20]))
                  .rename(['B3', 'B11'])
var mndwi2 = image2.expression('(green - swir) / (green + swir)' ,{
  'green':image2.select('B3'),
  'swir':image2.select('B11'),
}).rename('MNDWI2');
//adding the layer 
Map.addLayer(mndwi2.clip(roi), imageVisParam, 'MNDWI_2015');

//making water zones from 2020 mndwi image
var zones_2015 = mndwi2.gt(0.1).unmask(0);
Map.addLayer(zones_2015.clip(roi), VIS_WATER_MASK, 'water zones for 2015');

It is giving error :

MNDWI_2015: Layer error: Image.select: Pattern ‘B11’ did not match any
bands. water zones for 2015: Layer error: Image.select: Pattern ‘B3’
did not match any bands.

But as I am changing my year from 2015 to any other year it is working fine. Is there some issue with particular 2015 data or something wrong in the code? Some days back I apply the entire procedure for the same 2015 year for other area and everything works well but this time it is giving error for trying for other area.

Script link: https://code.earthengine.google.com/47dd2ed2fc7ca17b90c769e1c91ac971

One Answer

There are simply no images in 2015 for your defined filters (region, months and cloud percentage). You an check that using:

var numbImages = ee.ImageCollection('COPERNICUS/S2')
                  .filterDate('2015-06-23', '2015-12-31')
                  .filter(ee.Filter.lt('CLOUDY_PIXEL_PERCENTAGE', 20))
                  .filterBounds(roi).size();
print('numbImages 2015', numbImages)

Answered by Kuik on November 17, 2020

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP