Select features in feature collection where two properties are equal in Google Earth Engine (GEE)

feature-collectiongoogle-earth-engine

I feel like I am missing something basic here. I am looking to select only the features within a feature collection that have matching property values.

For example I would like to only select the second row where both fields have the exact same date (2019-08-09):

Field1date Field2date
2019-08-09 2019-08-08
2019-08-09 2019-08-09
2019-08-09 2019-08-10
2019-08-10 2019-08-08
2019-08-10 2019-08-09

If I export the feature collection from GEE to a .csv file I can do this simply with R with the following function:

datSelect<-data[data$Field1date==data$Field2date, ]

It would be great to do this before my Export.table.toDrive in GEE. I have tried with:

var datSelect = data.filterMetadata('Field1date', 'equals', 'Field2date');

But it returns zero elements.

Best Answer

Comparing field to field, you use the leftField, rightField arguments in ee.Filter.equals. (Also, you should basically never use filterMetadata)

data.filter(ee.Filter.equals({leftField: 'Field1date', rightField: 'Field2date'})
Related Question