In Earth Engine it is quite easy to create a median image out of several images from an image collection. But is there any way to get the information which particular images were used to create the median image?
1 Answer
You can do that by applying the aggregate_array
function over the filtered collection used to build the median image. In this function you need to specify the image property that corresponds to its name, which corresponds to the system:index
property. As you did not provide any example, here is a simple one.
In addition, if you wish to export the names of the images as a csv file, you can also do that by transforming the ee.List
(names of the images) into ee.Features
, then to a ee.FeatureCollection
and finally, export it using Export.table.toDrive
.
// Filter image collection
var imCol = ee.ImageCollection("LANDSAT/LE07/C01/T1_RT")
// Filter by spatial extent of a polygon
.filterBounds(ee.Geometry.Polygon(
[[[-102.10208697216933, 20.235359993650682],
[-102.10208697216933, 18.82723807089423],
[-100.52005572216933, 18.82723807089423],
[-100.52005572216933, 20.235359993650682]]], null, false))
// Filter by date
.filterDate('2008-01-01','2009-01-01')
// Filter by a property of the images, e.g., cloud cover land
.filter(ee.Filter.lte('CLOUD_COVER_LAND',20));
// Obtain median image
var reduced = imCol.reduce(ee.Reducer.median());
// Aggregate over a property of the images in the filtered image collection
// and obtain a list. In this case get the system:index property, which corresponds
// to the image name
var idList = imCol.aggregate_array('system:index');
// Print the list
print(idList);
// If you want to export it
// First transform list into Features
var exportFeatCol = idList.map(function(entry){
return ee.Feature(null, ee.Dictionary({id: entry}));
});
// Export and cast object as FeatureCollection
Export.table.toDrive({
collection: ee.FeatureCollection(exportFeatCol),
description: 'IdImages',
fileFormat: 'CSV'
});
-
Thanks for your comment. It is nice to know how I can create such a list but is it somehow possible to get the information which median pixels from which particular images were used for the median image? What I am aiming for is a list of almost cloud-free images over whatever region you like. This is how my code looks like: code.earthengine.google.com/b8385b06ad2e3b2cfaa69dd907b75599 It is quite simple but I was wondering if there is any way to get a more specific information on the images represented in the median image.– SimonCommented Jul 5, 2021 at 20:24