2

I'm working with filter in Google Earth Engine and I want to know what is the difference between these 2 filters:

  • ee.Filter.listContains(leftField, rightValue, rightField, leftValue)
  • ee.Filter.inList(leftField, rightValue, rightField, leftValue)

They use the same arguments, return the same results and when I call and print ee.ListContains filter I get ee.inList.

demo

1 Answer 1

0

You apply listContains() on List properties. You check if the list propertycontains the value you provide. inList() works the other way around, where you provide a list and check if the property is contained in your list.

Here are some examples that might explain it:

var collection = ee.ImageCollection("COPERNICUS/S1_GRD")
  .limit(1)

print('PROPERTIES', '----------')
print('transmitterReceiverPolarisation', collection.first().get('transmitterReceiverPolarisation'))
print('orbitProperties_pass', collection.first().get('orbitProperties_pass'))

print('FILTERED', '--------')
// listContains() on a List property.
// Valid use of this filter
print(collection
  .filter(ee.Filter.listContains('transmitterReceiverPolarisation', 'HH'))
  .aggregate_array('transmitterReceiverPolarisation')
)

// inList() on a List property where rightValue is a List of Strings.
// Invalid use of this filter, it will never match
print(collection
  .filter(ee.Filter.inList('transmitterReceiverPolarisation', ['HH']))
  .aggregate_array('transmitterReceiverPolarisation')
)
// inList() on a List property where rightValue is a List of Lists.
// Valid use of this filter.
print(collection
  .filter(ee.Filter.inList('transmitterReceiverPolarisation', [['HH', 'HV']]))
  .aggregate_array('transmitterReceiverPolarisation')
)

// listContains() on a String property.
// Invalid use of this filter, it gives an error
print(collection
  .filter(ee.Filter.listContains('orbitProperties_pass', 'DESCENDING'))
  .aggregate_array('orbitProperties_pass')
)

// inList() on a String property where rightValue is a List of Strings
// Correct use of this filter
print(collection
  .filter(ee.Filter.inList('orbitProperties_pass', ['DESCENDING']))
  .aggregate_array('orbitProperties_pass')
)

https://code.earthengine.google.com/56fec740caf60d45b4e223df38067621

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.