I have an image collection and a geometry ROI

var ROI = ee.Geometry.Rectangle(-78.20688664502586, 34.67650023609108, -77.65207707471336, 35.216816430066366); 

var l5 = ee.ImageCollection("LANDSAT/LT05/C01/T1_TOA")

When I print my image collection I get 190 images. However, some of the images cover only 10% of the ROI area. I would like to keep only the images that are integral contained in ROI. I have no idea how to do it.


Conceptually I believe the answer lies in the following filter. ee.Filter.contains() , however, I have never been able to implement it correctly.

Having said that, I do have a workaround. If you go to the inspector tab, and then click on the images that you are interested it (the ones that contain your ROI) you can see the WRS_PATH and WRS_ROW in the metadata of the image. They are 15 and 36 respectively. You can then filterMetadata() those values giving you only the images that match that criteria.

Add this to the bottom of your code and it will only be the images that you are interested in.

var filtered = l5.filterMetadata("WRS_PATH","equals",15)


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.