Search code examples
google-earth-enginesentinellandsat

How can I download each Sentinel-2 satellite data by date from Google Earth engine?


Hello! I would like to download Sentinel-2 satellite data for the year from January 1, 2023 to December 31, 2023 from Google Earth Engine, respectively by date.

I've written and run the script below, and I think maybe a year of data has been consolidated into one. I'd appreciate your help.

var image = ee.ImageCollection('COPERNICUS/S2_SR')
.filterDate('2023-01-01', '2023-12-31')
.filter(ee.Filter.lt('CLOUDY_PIXEL_PERCENTAGE',20))
.filterBounds(roi)
.median();

var visParamsTrue = {bands:['B4', 'B3', 'B2'], min:0, max:2500, gamma:1.1};
Map.addLayer(image, visParamsTrue, 'Sentinel 2A');
Map.addLayer(image.clip(roi), visParamsTrue, 'Research_Area');
Map.centerObject(roi, 10);

Export.image.toDrive({
  image:image.int16(),
  description:'Sentinel_2A',
  scale:10,
  region:roi,
  maxPixels:7699027
});

Solution

  • I am assuming you mean that you want to download the individual images for an entire year, rather than a composite?

    You are currently compositing all of the yearly images into one using the call .median() after you filter the collection. This essentially aggregates the images into a single image that you then export. You just need to remove the .median() call in your code.

    However, the internal GEE export call cannot export an entire collection. Instead, you could use the batch tools as explained thoroughly in this post https://gis.stackexchange.com/questions/248216/exporting-each-image-from-collection-in-google-earth-engine. This takes advantage of the Batch tools (documentation here) developed by Rodrigo Principe.