0

I am using GEE to download specific S2 tiles (by name) for some interval:

// Define the tile you want to download
var tileId = '14SLB'; 

// bands to download

var bands = ['B4', 'B3', 'B2', 'B1', 'B5', 'B6', 'B7', 'B8', 'B8A', 'B9', 'B11', 'B12', 'SCL']; // Example bands: blue, green, red, near-infrared, scene classification

// Define the date range
var startDate = '2022-05-01';
var endDate = '2022-05-30';

// Load the Sentinel-2 image collection for the specified tile
var collection = ee.ImageCollection('COPERNICUS/S2_SR_HARMONIZED')
  .filter(ee.Filter.eq('MGRS_TILE', tileId))
  .filterDate(startDate, endDate)
  .sort('system:time_start');


//iterate over collection

var S2_list = collection.toList(collection.size());
var l = collection.size().getInfo();

for (var i = 0; i < l; i++) {
  var image = ee.Image(S2_list.get(i));
  var acquisitionDate1 = image.date().format('YYYY-MM-dd');

  var filename = ee.String('S2_').cat(acquisitionDate1);
  var imageToDownload = image.select(bands).toUint16();
  var bounds = imageToDownload.geometry().bounds();
  //continue;
  Export.image.toDrive({
    image: imageToDownload,
    description: filename.getInfo(),
    folder: 'GEE_Images', // Specify the folder in your Google Drive
    scale: 10, // Adjust the scale if needed
    maxPixels: 1e13,
    region: bounds,
    crs: 'EPSG:4326' // Adjust the CRS if needed
  });


}

for a reason I don't understand for each tile I am getting two images, for example:

  1. S2_2022-05-02-0000000000-0000000000.tif ( ~ 3GB)
  2. S2_2022-05-02-0000000000-0000013056.tif (~30 MB)

where (1) contains almost 99% from the tile and (2) contains the negligible rest.

Why is that happening if I specifically chose an MGRS tile in my filtering and most importantly how can I download 1 image per tile (I don't need (2), (1) is enough for me) I have tried to omit the region and it made no difference.

1 Answer 1

2

The reason for the split is explained here:

https://developers.google.com/earth-engine/guides/exporting#large_file_exports

If the output image is large, it will be exported as multiple files. If you are exporting to GeoTIFF(s), the image is split into tiles. The filename of each tile will be in the form baseFilename-yMin-xMin where xMin and yMin are the coordinates of each tile within the overall bounding box of the exported image.

While it doesn't specify how large is "large", downloading a single S2 tile at 10m as in your example shouldn't be a problem. I tried the following:

Export.image.toDrive({
  image: ee.Image("COPERNICUS/S2_SR_HARMONIZED/20220502T171849_20220502T172612_T14SLB")
  .select("B3"),
  description:"test-export-single-tile",
  fileNamePrefix:"S2_2022-05-02",
  fileFormat: "GeoTIFF",
  folder:"",
  crsTransform:[10,0,300000,0,-10,3700020],
  crs:"EPSG:32614",
  maxPixels:1e9
  })

which resulted in a single S2_2022-05-02.tif image in my drive.

Perhaps your bounds region is larger than the actual footprint of the image and is larger than the threshold that the Export.image allows before splitting it into tiles.

2
  • I missed the part where you defined the bounds to be imageToDownload.geometry().bounds(), but you are still getting the image split into two. This (unanswered) question might be related as well gis.stackexchange.com/questions/457107/… May 25 at 12:15
  • Thank you, sorry, I forgot to paste it and added it after posting the original question.
    – user172775
    May 25 at 12:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.