Google Earth Engine – How to Filter FeatureCollection by Multiple Properties in Google Earth Engine

filtergoogle-earth-enginegoogle-earth-engine-javascript-api

I have a FeatureCollection ('results'), with several cloud probability values as properties (from different dates).

These properties are called "CLD01", "CLD02",…

I want to filter my collection in a way that only features remain which have 0 cloud probability at any given time, which means each of the "CLD" has to be 0.

I know how to filter my Feature collection by ONE of them:

var results_clear = results.filter(ee.Filter.eq('CLD01', 0))

I found here that I can filter my collection by multiple properties using this approach:

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

but it does not work with ".and" (also not with ".or", I tried it)

This is what I did:

var results_clear = results.filter(ee.Filter.eq('CLD01', 0)).and(ee.Filter.eq('CLD02', 0))

and I get this error:

Line 256: results.filter(…).and is not a function

I feel like this should be an easy thing to do but somehow…it isn't.

Best Answer

You can make use of ee.Filter.and to filter using both properties.

var results_clear = results.filter(ee.Filter.and(ee.Filter.eq('CLD01', 0),
                                                 ee.Filter.eq('CLD02', 0)));