In the below code I'm going to get image id in a function but returns error. Could anyone guide me please? How can I solve this?

enter image description here

code link: https://code.earthengine.google.com/154cea3df7a29cdf0a42b13f3a71f42c


var uhi = ee.ImageCollection("YALE/YCEO/UHI/Summer_UHI_yearly_pixel/v4")


// normalization process

var normal = function(img){
  var id = ee.String(img.get('system:id'))
  var min = ee.Number(img.reduceRegion(ee.Reducer.min(), table, 1000).get(id));
  var max = ee.Number(img.reduceRegion(ee.Reducer.max(), table, 1000).get(id));
  var normalization = (img.subtract(min)).divide(max.subtract(min));
  return normalization;

var uhiNormal = normal(uhi.select('Daytime'));

  • After using mean() at the beginning of the code, you lost the ID, because you are converting the collection into a single image (a mean composite). This composite does not have an id unless you set it.
    – HMSP
    Jun 9, 2021 at 14:39

1 Answer 1


As @HMSP pointed out, after using mean() at the beginning of the code, you lost the ID because you are converting the collection into a mean composite without any id. Following code produces normalized images (by using your normalization formula) with its respective id for each image in Image Collection.

Map.centerObject(table, 11);

var imageVisParam = {"opacity":1,

var uhi = ee.ImageCollection("YALE/YCEO/UHI/Summer_UHI_yearly_pixel/v4")

print("first image", uhi.first());

var id = ee.String(uhi.first().get('system:id'));

print("id first image", id);

// normalization process

var listOfImages = uhi.toList(uhi.size());

var normal = listOfImages.map(function (img){
  var id = ee.String(ee.Image(img).get('system:id'));
  var min = ee.Image(img)
    .reduceRegion(ee.Reducer.min(), table)
  var max = ee.Image(img)
    .reduceRegion(ee.Reducer.max(), table)
  var normalization = (ee.Image(img)
  return normalization.set('system:id', id)


print("List of images in Image Collection", normal);
Map.addLayer(ee.Image(normal.get(0)),imageVisParam, 'normalized');

First image of normalized collection is added to Map Canvas for verification purpose. It can be observed in following picture.

enter image description here

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.