0

I am a new Google Earth Engine user. I am trying to remove some images of an image collection. In the example below is a example. My image collection has more images.

 // Load Landsat 8 brightness temperature data for 1 year.
 var test = ee.ImageCollection('LANDSAT/LC8_L1T_32DAY_TOA')
.filterDate('2012-12-25', '2016-12-25')
.select('B1');
print(test)

My image collection has 45 images. To be clear, I will call index1 my first image and index45 my last image, etc. How could I keep or remove the images from index10 to index 15 and from index30 to index40.

I tried with a list but it does not work to capture the elements.

Donam1987
  • 3
  • 1
  • 2

2 Answers2

0

You can filter a collection by its metadata using the following function.

.filterMetadata(name, operator,value)

If the images you want to keep have a value that is the same, then you can use that. for Example, to filter by WRS_ROW and WRS_PATH you would do the following.

var testFiltered = test.filterMetadata("WRS_ROW","equals",15)
                       .filterMetadata("WRS_PATH","equals",36)

Just pick the metadata that works best for you. It is better not to select by number, as then they won't work on other years.

Sean Roulet
  • 116
  • 2
0

In addition to filtering by metadata properties such as the WRS-2 path and row, you can also run the method .filterBounds(geometry) for a collection and it will result in a new collection with only elements that intersect with the geometry. Here is an example:

// Load Landsat 8 TOA data.
var timeFiltered = ee.ImageCollection('LANDSAT/LC08/C01/T1_TOA')
    .filterDate('2013-01-01', '2014-01-01');

// define an ee.Geometry to filter by
// San Francisco Lon/Lat
var geom = ee.Geometry.Point([122.4194, 37.7749]);

// filter by a geometry
var spaceTimeFiltered = timeFiltered.filterBounds(geom);

print('Before spatial filtering: ',timeFiltered);
print('After spatial filtering: ',spaceTimeFiltered);

In this case, the collection only filtered by time will not print because it has over 5000 elements but when you filter by space and time it returns 15 scenes from 2013 that are over San Francisco.

Kel Markert
  • 807
  • 4
  • 12