I built a function to add a a new band (b1_1) to each image of a image collection and I mapped it. It does seem to work, at least when printing the image collection and inspecting it in the console.

But when I trying to map on the "new collection" another function for charting the new band (b1_1) against some other pre-existing band, the new one doesn't exist anymore.

//mask and add delta DEM band
var add_band = function(image){
var glacier_img = image.select(['b1']);
var glacier_clip = glacier_img.clip(shp);
var dem_glacier = DEM_delta.clip(shp);

var vel_range = glacier_clip.lte(ee.Number(700)).and(glacier_clip.gte(ee.Number(-700)));
var dem_glacier_mask = dem_glacier.updateMask(vel_range);

var final_img = image.updateMask(vel_range).addBands(dem_glacier_mask);
return final_img;


//add a DEM band  to each image of the images collection
var imgCollection = imgCollection.map(add_band); 

var graph = function(image){
var id = image.id;
var image = ee.Image(image.id);

var result = image.reduceRegion(ee.Reducer.toList(),shp, 200);
var y = ee.Array(result.get('b1'));
var x = ee.Array(result.get('b1_1'));
var chart = ui.Chart.array.values(y, 0, x)
        title: 'Velocity vs. Delta_DEM ',
        hAxis: {'title': 'Delta_DEM'},
        vAxis: {'title': 'Velocity'},
        pointSize: 3,

  // Print the chart.
  return print(chart);

 imgCollection.evaluate(function(imgCollection) {  // use map on client-side

enter image description here enter image description here

  • 4
    Welcome to GIS SE. Please, take the tour and edit your question. Post formatted code and add add_band function to the question
    – aldo_tapia
    Dec 20 '18 at 11:35
  • Your code has an image variable defined somewhere above line 48, but you declaring another global variable image in line 70. This can't be a good idea. Dec 20 '18 at 20:23
  • Please post a minimal example that can be reproduced by others. Dec 20 '18 at 20:23
  • This code is not reproducible but I would suggest explicitly renaming the band you're adding using .rename('L1_1') or whatever after your .addBands() argument. Dec 20 '18 at 20:31

The problem is that you're attempting to use evaluate() on an entire imagecollection. The result from evaluate is just some metadata; the results are no longer images; they're just small dictionaries containing the image metadata.

If you're hoping to generate a chart per image for every image in a collection, you'll have to use a traditional for loop and get each image out of the collection 1 at a time (collection.toList(1, index). But there is no evaluate in that process.

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.