Is it possible to use an equality filter for a FeatureCollection in GEE based on multiple values? I understand how to filter by one value:


But what if I wanted to filter by a list of values? Something like:

var lis = ee.List(['VALUE1', 'VALUE2', 'VALUE3']);

Is it possible to apply this to equality filter? I tried to do the following:


It ran, but didn't work.


The inList filter is what you want for looking for any value in a list:

collectionName.filter(ee.Filter.inList('COLUMN', lis))

If instead you want to use several filters (so that you can use other conditions than equality, or multiple properties), you can use ee.Filter.or:

  ee.Filter.eq('COLUMN', 'VALUE1')
    .or(ee.Filter.eq('COLUMN', 'VALUE2'))
    .or(ee.Filter.eq('COLUMN', 'VALUE3')))

This is the same as the first filter but can be changed to look at different properties, for example. If you already have a simple list of values, inList is the right tool.

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.