I'm trying to do TCT for Sentinel-2 in GEE. I was wondering if anyone has a clue to do it because I'm stuck at merge my photo collection into one photo to then apply the coefficient. I also want to know what should I do next. What I did : download all my photo in level 1C, apply a cloud mask and then I resample at 10 m (I know it is normally not possible to do it at 10 m but I want to try and otherwise I'll resample at 20 m). This is my code :
var geometry = ee.Geometry.Polygon([
[
[-115.73847882052277, 68.01627877927311],
[-115.73847882052277, 67.67657244934614],
[-114.83759991427277, 67.67657244934614],
[-114.83759991427277, 68.01627877927311]
]
]);
// Define the time range for July from 2016 to 2023
var startDate = '2016-07-01';
var endDate = '2023-07-31';
// Filter Sentinel-2 imagery for July of each year from 2016 to 2023
var s2 = ee.ImageCollection('COPERNICUS/S2')
.filterBounds(geometry)
.filterDate(startDate, endDate)
.filter(ee.Filter.lt('CLOUDY_PIXEL_PERCENTAGE', 20)); // Adjust cloud cover threshold as needed
// Cloud masking function
function maskS2clouds(image) {
var qa = image.select('QA60');
var cloudBitMask = 1 << 10;
var cirrusBitMask = 1 << 11;
var mask = qa.bitwiseAnd(cloudBitMask).eq(0)
.and(qa.bitwiseAnd(cirrusBitMask).eq(0));
return image.updateMask(mask).divide(10000);
}
// Define a list of years
var years = ee.List.sequence(2016, 2023);
// Create a monthly composite for July of each year
years.evaluate(function(years) {
years.map(function(year) {
var startDate = ee.Date(year + '-07-01');
var endDate = ee.Date(year + '-07-31');
var imagesOfYear = s2.filterDate(startDate, endDate).map(maskS2clouds);
if (count.gt(0)) {
var composite = imagesOfYear.median();
var imageVisParam = {bands: ['B4', 'B3', 'B2'], min: 0, max: 0.3};
Map.addLayer(composite, imageVisParam, 'Composite ' + year);
// Rééchantillonnage de l'image à une résolution de 10 mètres
var composite_10m = composite.reproject({
crs: composite.projection(), // Utilisez la même projection que l'image d'origine
scale: 10 // Résolution spatiale de 10 mètres
});
});
}
});
});
// Print the number of images found
var count = s2.size();
print('Number of Sentinel-2 images found for July between 2016 and 2023:', count);
// Visualize the images
Map.centerObject(geometry, 8);` ``
Otherwise, if you have other ways to do it I'll be happy to read from you.