[GIS] How to filter image collection by date, excluding a date from a date range in Google Earth Engine

filtergoogle-earth-engine

I am using air surface temp data from 2015 in Google Earth Engine but there is missing data for June 19, 2015 which is assigned the value 9.9621e+36.

So I need to create a date range from Jan 1 2015 to Dec 31 2015 which excludes June 19 2015. I know how to filter by date:

var AST2015 = ee.ImageCollection('NCEP_RE/surface_temp')
                .filterDate('2015-01-01', '2015-12-31');

But as long as that one June date is in their my mean and other stats are ruined. SOS

Best Answer

You can remove images from an image collection by creating a date filter for the 'bad/missing' data and then remove it using ee.Filter.not(). For example:

var collection = ee.ImageCollection('NCEP_RE/surface_temp');
var AST2015 = collection.filterDate('2015-01-01', '2016-01-01');

var start_bad_data = '2015-06-18T00:00:00';
var end_bad_data = '2015-06-20T00:00:00';
var bad_data_filter = ee.Filter.date(start_bad_data, end_bad_data);

// Select the bad data.
var AST2015_bad_data = AST2015.filter(bad_data_filter);
// Select the good data.
var AST2015_good_data = AST2015.filter(bad_data_filter.not());

Map.addLayer(AST2015, {}, 'AST2015');
Map.addLayer(AST2015_bad_data, {}, 'AST2015_bad_data');
Map.addLayer(AST2015_good_data, {}, 'AST2015_good_data');