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.

  • I edited my answer to fit your clarified question. Aug 17, 2021 at 6:47

2 Answers 2


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'})
  • Thank you Noel!!! works as advertised and thanks for the tip on filterMetadata. The line now reads in GEE: var datSelect = data.filter(ee.Filter.equals({leftField: 'Field1date', rightField: 'Field2date'}))
    – vsjansen
    Aug 17, 2021 at 15:41
  • Is filterMetadata() inherently inefficient? or only in this case? Aug 18, 2021 at 2:25
  • It's only equivalent to one combination (leftField+rightValue), and it's always longer (more typing) than the other options (ie: filter('property == value'), even if that's all you wanted. Aug 18, 2021 at 17:13

Though not quite as easy as in R, but I understand better what you are trying to do.

There might be an easier way to do it, but this is the only way I can think of doing it.

First you will have to go through a function that will check if each feature has the same value in both properties and set a new property with the result of that check (Pass or Fail). Here we will find the difference between the 2 dates (and you may have to add the ee.Date() so that it knows it is dealing with a date). If the difference is 0 then earth engine will go to the second part of the ee.Algorithms.If() (making it pass). If the difference is not 0 then it will go to the first part.

The result is you will have a featureCollection that has a new property added Pass that will either have a value of Yes or No.

From that you simply filterMetadata() to the value you are interested in. So now onlyEqualDates will contain the features that meet your criteria.

var onlyEqualDates = data.map(function(feature){
  return ee.Algorithms.If(feature.getDate("Field1date").difference(feature.getDate("Field2date"),"day"),
                          feature.set("Pass", "No"),

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.