I have to filter a Featurecollection with a certain threshold. This threshold is defined in a different Featurecollection. I want to use a simple join to filter the collection. However, if I do it it returns more then I expect. What am I doing wrong?

var threshold5 = threshold4.filter(ee.Filter.lessThanOrEquals('x',0.7))

// next a function is needed to sum and find the minimum. The minimum is saved, toghether with the bandname
var unweighted = function(img){
  var uni = img.reduceRegions({
    reducer: ee.Reducer.sum().unweighted(),
    collection: grid,
      var id = ee.String(feat.get('system:index')).cat('-').cat(ee.String(img.get('system:index')));
      var date = ee.String(img.get('system:index'));
      var bandNames = img.bandNames().map(function(name){return ee.Number.parse(name)});
      var values = ee.Feature(feat).toDictionary(img.bandNames()).values();
      var array = ee.Array.cat([values, bandNames], 1);
      var min = array.reduce(ee.Reducer.min(2), [0], 1);
      var key = ee.String(min.get([0,1]).toInt());
      var value = min.get([0,0]);
      return ee.Feature(feat.setMulti(ee.Dictionary.fromLists(['Minimum', 'value', 'id'], [key, value, id])));
    return uni; 

var C = B.map(unweighted).flatten();
var joinfilter = ee.Filter.stringContains({leftField:'id',rightField:'id'})
var join = ee.Join.simple().apply({
  condition: joinfilter

link to full code


My guess is that your joinfilter isn't what you expect.

Try replacing:

var joinfilter = ee.Filter.stringContains({leftField:'id',rightField:'id'})


var joinfilter = ee.Filter.equals({leftField:'id',rightField:'id'});
| improve this answer | |

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.