Monday, 29 July 2019

landsat 7 - remove one image from imageCollection in google earth engine


I work with google earth engine on an imageCollection from landsat7. Some of those images are 'corrupted'. So I would like to remove one image from an image collection.


Actually I have :


var collectionLS7NDVI0 = ee.ImageCollection('LANDSAT/LE7_L1T_32DAY_NDVI')
.filter(ee.Filter.calendarRange(6,6,'month'))
.map(addTime);


var listOfImages = collectionLS7NDVI0.toList(collectionLS7NDVI0.size());
print(listOfImages)
0:
Image LANDSAT/LE7_L1T_32DAY_NDVI/19990610 (2 bands)
1:
Image LANDSAT/LE7_L1T_32DAY_NDVI/20000609 (2 bands)
2:
Image LANDSAT/LE7_L1T_32DAY_NDVI/20010610 (2 bands)
3:

Image LANDSAT/LE7_L1T_32DAY_NDVI/20020610 (2 bands)
4:
Image LANDSAT/LE7_L1T_32DAY_NDVI/20030610 (2 bands)
5:
Image LANDSAT/LE7_L1T_32DAY_NDVI/20040609 (2 bands)
6:
Image LANDSAT/LE7_L1T_32DAY_NDVI/20050610 (2 bands)
7:
Image LANDSAT/LE7_L1T_32DAY_NDVI/20060610 (2 bands)
8:

Image LANDSAT/LE7_L1T_32DAY_NDVI/20070610 (2 bands)
9:
Image LANDSAT/LE7_L1T_32DAY_NDVI/20080609 (2 bands)
10:
Image LANDSAT/LE7_L1T_32DAY_NDVI/20090610 (2 bands)
11:
Image LANDSAT/LE7_L1T_32DAY_NDVI/20100610 (2 bands)
12:
Image LANDSAT/LE7_L1T_32DAY_NDVI/20110610 (2 bands)
13:

Image LANDSAT/LE7_L1T_32DAY_NDVI/20120609 (2 bands)
14:
Image LANDSAT/LE7_L1T_32DAY_NDVI/20130610 (2 bands)
15:
Image LANDSAT/LE7_L1T_32DAY_NDVI/20140610 (2 bands)
16:
Image LANDSAT/LE7_L1T_32DAY_NDVI/20150610 (2 bands)
17:
Image LANDSAT/LE7_L1T_32DAY_NDVI/20160609 (2 bands)


And I want to remove images 6 (2005).


Any ideas are welcome


Etienne



Answer



You can remove images of a collection by constructing a filter that selects the images you want to remove, then negate the filter using ee.Filter.not().


var MAX_LIST_SIZE = 100;

var collectionLS7NDVI0 = ee.ImageCollection('LANDSAT/LE7_L1T_32DAY_NDVI')
.filter(ee.Filter.calendarRange(6,6,'month'));
print('listOfImages', collectionLS7NDVI0.toList(MAX_LIST_SIZE));


// Filter out image(s) from 2005.
var filtered = collectionLS7NDVI0.filter(
ee.Filter.date('2005', '2006').not()
);
print('filtered', filtered.toList(MAX_LIST_SIZE));

No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...