0

I would like to merge a collection of images (unknown amount) of a polygon into a single image and then export it to google drive for analysis in qgis. This is the code I have tried to us

// Define the AOI
var aoi = XXX;
Map.centerObject(aoi);
Map.setOptions('SATELLITE');

var dataset = ee.ImageCollection('UQ/murray/Intertidal/v1_1/global_intertidal');

var visualization = {
  bands: ['classification'],
  min: 0.0,
  max: 1.0,
  palette: ['0000FF']
};


Map.addLayer(dataset, visualization, 'Intertidal areas');

I have tried the following code to export the image, but obviously because I am viewing a collection of images, I cannot export a single image of the mosaic

// Export to base Google Drive 
Export.image.toDrive({ image: FraserRiver , description: 'exportToDrive', fileNamePrefix: ' FraserRiver', scale: 30, region: aoi, maxPixels: 800000000000 });
  • It sounds like you are looking to make a mosaic. This happens implicitly when you visualize an imagecollection - where images overlap, it will automatically put the most recent image on top. You need to do this explicitly and assign the output to a variable that you can then export. Try https://developers.google.com/earth-engine/guides/ic_composite_mosaic for starters. Note that you can make mosaics in many ways - most recent pixels, greenest pixels, cloud-free pixels, etc. Once you create a single image, then you can export it. – Anson Call Nov 04 '22 at 18:01

1 Answers1

0

This code simply extracts all bands within an image collection and put them in one single image (got the idea from https://www.nature.com/articles/s41597-021-00827-9):

// Function to merge bands
var mergeBands = function(image, previous) {
  return ee.Image(previous).addBands(image);
};
// Merge bands
var image = ee.Image(mycollection.iterate(mergeBands, ee.Image([])))