// Define the bounding box for Sleman, Yogyakarta, Indonesia
var boundingBox = ee.Geometry.Rectangle(110.3033, -7.7895, 110.4648, -7.6891);
// Define the time range
var start_date = ‘2022-01-01’;
var end_date = ‘2022-12-31’;
// Filter Sentinel-2 data by AOI, time, and cloud cover (less than 10%)
var collection = ee.ImageCollection(“COPERNICUS/S2”)
.filterBounds(boundingBox)
.filterDate(start_date, end_date)
.filter(ee.Filter.lt(“CLOUDY_PIXEL_PERCENTAGE”, 10)); // Adjust the cloud cover threshold as needed
// Create a cloud-free composite using median
var composite = collection.median();
// Display the composite on the map
Map.centerObject(boundingBox, 12);
Map.addLayer(composite, {bands: [“B4”, “B3”, “B2”], min: 0, max: 3000}, “RGB Composite”);
// Export the composite to Google Drive
Export.image.toDrive({
image: composite.select([“B1”, “B2”, “B3”, “B4”, “B5”, “B6”, “B7”, “B8”, “B8A”, “B9”, “B10”, “B11”, “B12”]),
description: ‘Sentinel2_AllBands_Composite_Sleman’,
scale: 10,
region: boundingBox
});