4

I am trying to filter a Sentinel-2 collection by the system:index property. I have selected three specific tiles identified by its respective id, then tried filtering them from a collection using filter(ee.Filter.eq()) function, but it does not load any image. It works well for filtering only one image id, but is not working with several at the same time.

var tiles = [
  '20190129T160521_20190129T161214_T17RMN',
  '20190106T160511_20190106T160506_T17RNJ',
  '20190106T160511_20190106T160506_T17RNK'
]

var filtered = ee.ImageCollection('COPERNICUS/S2')
  .filter(ee.Filter.eq('system:index', tiles))

print(filtered.size());

https://code.earthengine.google.com/51da7be720dd9e67e9e32fa3c6fafb85?noload=true

2 Answers 2

6

You can simply use the ee.Filter.inList() filter:

var tiles = [
  '20190129T160521_20190129T161214_T17RMN',
  '20190106T160511_20190106T160506_T17RNJ',
  '20190106T160511_20190106T160506_T17RNK'
]

var filtered = ee.ImageCollection('COPERNICUS/S2')
  .filter(ee.Filter.inList('system:index', tiles))

print(filtered.size());
0
0
var tiles = [
  '20190129T160521_20190129T161214_T17RMN',
  '20190106T160511_20190106T160506_T17RNJ',
  '20190106T160511_20190106T160506_T17RNK'
]

var filtered = ee.ImageCollection('COPERNICUS/S2')
  .filter(ee.Filter.equals('system:index', tiles))

print(filtered.size());
2
  • use ee.Filter.equals() filter...it worked for me! Commented Nov 10, 2023 at 6:34
  • 3
    As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.
    – Community Bot
    Commented Nov 10, 2023 at 6:45

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.