0

How do I create a stacked image from an image collection of Sentinel 1 images over a period?

I am selecting only the ascending mode, and the VH polarization. If I use ".toBands()" at the end of the coding, it is creating a stacked image. However, the band names are quite long mentioning their properties, like "S1A_IW_GRDH_1SDV_....VH". I want the names to be like "b1", "b2"....and so on.

I am using the following code:

// Filter the collection for the VH product from the descending track
var sentinel1A = ee.ImageCollection('COPERNICUS/S1_GRD')
                    .filterDate('2021-06-01', '2021-11-16')
                    .filter(ee.Filter.listContains('transmitterReceiverPolarisation', 'VH'))
                    .filter(ee.Filter.eq('instrumentMode', 'IW'))
                    .filter(ee.Filter.or(ee.Filter.eq('orbitProperties_pass', 'ASCENDING')))
                    .select('VH')
                    .filterBounds(ROI)
                    .toBands();


print (sentinel1A, 'S1A');
Map.addLayer(sentinel1A, {}, 'S1A');
2
  • Could you describe what you intend to do with the output of toBands()? That might help lead to a better solution that avoids the problem by avoiding toBands().
    – Kevin Reid
    May 29, 2022 at 14:17
  • Actually, I want a stacked image of all the dates available in that image collection. Suppose, that the image collection has imageries of 5 dates. I want an image with the bands described as band1=date1, band 2=date 2and so on. Finally, I want the backscatter coefficient for particular pixels from the stacked image. May 29, 2022 at 14:44

1 Answer 1

1

You first need to create a list with the band names you are going to use to replace the current image/band names. The list has to be the same length as the number of bands.

var names = ee.List.sequence(0,sentinel1A.bandNames().size().subtract(1))
  .map(function(element){
    return ee.String('b').cat(ee.Number(element).toInt())
  });

Then once you have that list you simply apply the .rename() function like this:

var sentinel1ARenamed = sentinel1A.rename(names);
print(sentinel1ARenamed);
6
  • You are right, although this is a commentary instead of an answer. Please elaborate it
    – aldo_tapia
    Jun 7, 2022 at 21:20
  • Could you please elaborate a little with the above code I provided? If there are 14 images in the collection, how do I convert only one polarized channel, e.g., VH of all the 14 images into 14 bands and stack them to create a 14 band image? Where should I use the .rename() command? Jun 8, 2022 at 15:44
  • @SwadhinaKoley I've edited my answer, hope it helps
    – M. Nicolas
    Jun 8, 2022 at 16:55
  • 1
    Excellent, now this is a great answer
    – aldo_tapia
    Jun 8, 2022 at 17:00
  • @M. Nicolas Thank you so much! Aug 8, 2022 at 6:03

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.