6

I have an image collection of Sentinel-1 data over 3 years filtered by a region of interest that spans 3-4 tiles, and want to know the best way to mosaic all the images (tiles) that were taken on the same day into one image. Currently filtering by date yields separate images for each separate tile, and I would like to merge all images (tiles) from the same day into one image.

I know how to do this for one specified date with a command like this:

ee.Image(collection.filterDate('2014-10-01','2014-10-02').mosaic())

But I would like to do this iteratively for the whole collection in my ROI over a broad date range and obtain a new image collection of mosaicked images by days in which there is some data.

The collection is created by the following code:

var poly = /* color: #d63000 */ee.Geometry.Polygon(
    [[[-76.0803, 10.8656],
      [-76.0913, 7.7436],
      [-73.1909, 7.7545],
      [-73.3776, 9.4273],
      [-75.2124, 10.9304]]])

var start = ee.Date('2014-10-01');
var finish = ee.Date('2018-03-31');

var collection = ee.ImageCollection('COPERNICUS/S1_GRD')
.filterDate(start, finish)
.filter(ee.Filter.listContains('transmitterReceiverPolarisation', 'VV'))
.filter(ee.Filter.listContains('transmitterReceiverPolarisation', 'VH'))
.filter(ee.Filter.eq('instrumentMode', 'IW'))
.filterMetadata('resolution_meters', 'equals', 10)
.filterBounds(poly);

For example, the first three images in this collection are all tiles from the same day (2014-12-02), and I would like to mosaic them together into one 3-tile image for day 2014-12-02, and then do this for the entire collection of over 500 tiles/images to get a collection of day-unique tile mosaics.

  • 1
    can you post the entire code or the link to the Code Editor? – Rodrigo E. Principe Apr 20 '18 at 10:50
  • Ok done, see above edits. Hope that helps. – deepsky Apr 20 '18 at 16:17
  • @Rodrigo E. Principa: One question to your above solution. Is it possible to conserve the date for each mosaic in order to differentiate between the resulting mosaics? – erg Oct 31 '18 at 22:12
10
var poly = /* color: #d63000 */ee.Geometry.Polygon(
    [[[-76.0803, 10.8656],
      [-76.0913, 7.7436],
      [-73.1909, 7.7545],
      [-73.3776, 9.4273],
      [-75.2124, 10.9304]]])

var start = ee.Date('2014-10-01');
var finish = ee.Date('2018-03-31');

var collection = ee.ImageCollection('COPERNICUS/S1_GRD')
.filterDate(start, finish)
.filter(ee.Filter.listContains('transmitterReceiverPolarisation', 'VV'))
.filter(ee.Filter.listContains('transmitterReceiverPolarisation', 'VH'))
.filter(ee.Filter.eq('instrumentMode', 'IW'))
.filterMetadata('resolution_meters', 'equals', 10)
.filterBounds(poly);

// Difference in days between start and finish
var diff = finish.difference(start, 'day')

// Make a list of all dates
var range = ee.List.sequence(0, diff.subtract(1)).map(function(day){return start.advance(day,'day')})

// Funtion for iteraton over the range of dates
var day_mosaics = function(date, newlist) {
  // Cast
  date = ee.Date(date)
  newlist = ee.List(newlist)

  // Filter collection between date and the next day
  var filtered = collection.filterDate(date, date.advance(1,'day'))

  // Make the mosaic
  var image = ee.Image(filtered.mosaic())

  // Add the mosaic to a list only if the collection has images
  return ee.List(ee.Algorithms.If(filtered.size(), newlist.add(image), newlist))
}

// Iterate over the range to make a new list, and then cast the list to an imagecollection
var newcol = ee.ImageCollection(ee.List(range.iterate(day_mosaics, ee.List([]))))
print(newcol)

https://code.earthengine.google.com/20ad3c83a17ca27b28640fb922819208

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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