Say I have a dictionary in Earth Engine as follows:

var dictionary = ee.Dictionary({
  key1: null,
  key2: null,
  key3: null

How do I use the map() function to change all the values of each key to a string "NoData" instead of null? According to the documentation for map(), I need to write a function consisting of two arguments: a key from a dictionary and a value, though I am unsure how to write this.


For your particular example, you can do this:

// map over the dictionary
var mappedDictionary = dictionary.map(function(key, val){
  return 'noData';

If you have non-null data in the dictionary, you could also use the val argument, see the example in the link.

Link code

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.