I am adding two properties to each feature in a feature collection based on two images within each feature, currently represented as properties themselves. I got this feature collection through performing an inner join on two image collections. To add them, I am running this function:

var innerJoined = innerJoin.apply(perpSum, finalSent2, filterTimeEq);

var test = innerJoined.map(function(feature) {                                                             
  var percObs = ee.Image(feature.get('primary')).reduceRegion(                                             
      {geometry: studyArea.geometry(), reducer: ee.Reducer.median(), scale: 30}).get('precipitation');     
  var NDTIObs = ee.Image(feature.get('secondary')).reduceRegion(                                           
      {geometry: nilo, reducer: ee.Reducer.median(), scale: 30}).get('NDTI');                              
  return feature.set('precipitation', percObs).set('NDTI', NDTIObs.get('NDTI'));                           
print('test2', test2);                                         

However, when I run the code, I get this error:

FeatureCollection (Error)
Error in map(ID=74_74): Dictionary.get: Dictionary does not contain key: precipitation

When I've been debugging, I've found that if I just take 1 feature and apply a similar version of the code that is in the function, I don't get the error, and the value I want gets added to the feature properties:

var feat = innerJoined.first();

var percObs = ee.Image(feat.get('primary')).reduceRegion(                                             
      {geometry: studyArea.geometry(), reducer: ee.Reducer.median(), scale: 30}).get('precipitation');
var test1 = feat.set('precipitation', percObs);
print('test1', test1);

Because I can get around this issue if I do not use the function, I think it is the function that is causing the problem. However, I haven't found a precedent for this problem yet, or anything in the documentation that I have found helpful.

Is the function the problem, or I am I doing something in the single addition of the property that I am not doing in the function?

If you want to see the full code that is commented out, you can do so here: https://code.earthengine.google.com/8e2656ba08560e002e422b1a05aaa555 To see the issue area please scroll to the bottom with the area marked "Focus area"

1 Answer 1


The primary image in the last feature in your join (with system:index = "74:74"), has no bands. So the reduceRegion returns nothing. That image corresponds to 2031-03, for which data doesn't exist in the CHIRPS dataset yet.

You can simply filter that image out of the perpSum result before joining with it.

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.