I want to analyze Sentinel-2 data from January to the present, but the data is only accessible until February 7th, 2024. Here’s an example of the GEE code for visualizing Sentinel-2 data in RGB, which only functions until that date. Does anyone know what’s happening or how to resolve this issue? Thanks in advance for your help.
/**
* Function to mask clouds using the Sentinel-2 QA band
* @param {ee.Image} image Sentinel-2 image
* @return {ee.Image} cloud masked Sentinel-2 image
*/
function maskS2clouds(image) {
var qa = image.select('QA60');
// Bits 10 and 11 are clouds and cirrus, respectively.
var cloudBitMask = 1 << 10;
var cirrusBitMask = 1 << 11;
// Both flags should be set to zero, indicating clear conditions.
var mask = qa.bitwiseAnd(cloudBitMask).eq(0)
.and(qa.bitwiseAnd(cirrusBitMask).eq(0));
return image.updateMask(mask).divide(10000);
}
var dataset = ee.ImageCollection('COPERNICUS/S2_SR_HARMONIZED')
.filterDate('2024-03-01', '2024-03-30')
// Pre-filter to get less cloudy granules.
.filter(ee.Filter.lt('CLOUDY_PIXEL_PERCENTAGE',20))
.map(maskS2clouds);
var visualization = {
min: 0.0,
max: 0.3,
bands: ['B4', 'B3', 'B2'],
};
Map.setCenter(83.277, 17.7009, 12);
Map.addLayer(dataset.mean(), visualization, 'RGB');
I tried with former collections but it didn’t work too.
New contributor
theo marichal is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.