1

I'm trying to calculate a sintetic band, rename it and add to image collection in order to constitute a natural false color ASTER images.

enter image description here

    //Filtering

var image = imageCollection2.filterBounds(geometry)
                          .filterDate('2000','2021')
                          .filterMetadata('CLOUDCOVER', 'less_than',0.5)
                          ;




//Calculate a new band and renaming it

var image_sint = image.map(function (image){
  var  sint = image.expression(
    '((banda1 *3)+banda3)/4',
    {'banda1': image.select('B01'),
    'banda3' : image.select('B3N')
    }).rename('sint');
    return image.addBands('sint');
});


//Visual Parameters

var paramvis = {bands: ['B02','sint','B01' ]};


//Adding to view
Map.addLayer(image_sint, paramvis,'final');

2 Answers 2

1

This approach fix the problem:

//Filtering

var image = imageCollection2.filterBounds(geometry)
                          .filterDate('2000','2021')
                          .filterMetadata('CLOUDCOVER', 'less_than',0.5)
                          ;

//Calculate a new band and renaming it

var image_sint = image.map(function (image){
  return image.expression(
    '((banda1 *3)+banda3)/4',
    {'banda1': image.select('B01'),
    'banda3' : image.select('B3N')
    }).rename('sint').addBands(image);
});


//Visual Parameters

var paramvis = {bands: ['B02','sint','B01' ]};


//Adding to view

Map.addLayer(image_sint, paramvis,'final');


here a example: link

0

The problem is that you are trying to add a string as a new band instead of the name of the object of interest. Just remove the single quotations around sint in addBands.

return image.addBands(sint);

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.