2

I would like to know how to handle ee.Imagecollection output for mosaic. I am trying to use AOI shapefile to identify the Landsat TM 5 imagery.

var start= ee.Date('1987-01-01');
var end  = ee.Date('1988-01-01'); 
var collection= ee.ImageCollection('LANDSAT/LT5')
    .filterBounds(fc)//fc is shapefile variable 
    // .filterBounds(city)
    .filterDate(start, end)
    .aside(print)
    .sort('CLOUD_COVER',false); 
 print ('ImageCollection', collection);

which results in

ImageCollection LANDSAT/LT5 (6 elements)
type: ImageCollection
id: LANDSAT/LT5
version: 1502218468957000
bands: []
features: List (6 elements)
properties: Object (17 properties)

then I use following function to mosaic it.

var customComposite = ee.Algorithms.Landsat.simpleComposite({
    collection: collection,
    percentile: 10,
    cloudScoreRange: 5
});

The output is single mosaic image, but how I can know which images were used for mosaic and How I can run mosaic on the all 6 elements?

1 Answer 1

1

First of all I think you misunderstand the concepts, simpleComposite makes a composite and not only a mosaic, for mosaicing you have mosaic. So,

How I can run mosaic on the all 6 elements?

in your code you are making a composite of all 6 images

how I can know which images were used for mosaic?

The only way you have is to create a band in every image that makes some reference to the image itself. But you are bounded to the data types. For example, you couldn't create a band for image ids (str). But you could think in a workaround. It depends on your data.

You have at least 2 more options for making a composite, if you have a quality band you can use ImageCollection.qualityMosaic() (in my opinion this function mistakes the concepts too) and if you are doing a more complex operation you also have arrays, could be something like:

var col = ee.ImageCollection(ID)
var arr = col.toArray()
var qb = arr.arraySlice(1, 1, 2)
var sorted = arr.arraySort(qb)

And so on.

4
  • The names "mosaic" and "composite" are unfortunate because both functions do both operations. In the case of mosaic(), the compositing method is based on the sort order of the input collection: last pixels on top. If the collection is sorted chronologically, mosaic() creates a most recent value composite. Since the median that's built into SimpleComposite is applies band-wise, each band in each pixel could come from a different image. Commented Aug 17, 2017 at 17:39
  • Totally right. I didn't explain much the mosaic function, but that is it. At first I was thinking in just leave a comment, but the answer wasn't so far. But you can edit it or make another. Commented Aug 17, 2017 at 19:04
  • Thanks for clarification, you are correct I did misunderstood simpleComposite. // Sort by a cloud cover property, get the least cloudy image. var image = ee.Image(collection.sort('CLOUD_COVER')); print('Least cloudy image: ', image); gives me sorted list of images from list cloudy to higher.
    – uday
    Commented Aug 18, 2017 at 4:58
  • 1
    I am not a moderator, but be aware of the stackexchange protocol, I think this answer should've been a comment. I will edit my answer to give you a extra pair of options. Commented Aug 18, 2017 at 10:36

Your Answer

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

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