I am trying to filter an Image collection in google earth engine, but it seems that my metadata filter based on irradiance has no discernable effect on the output. Values above the threshold are still kept in the ImageCollection, but if I reduce the value too low, no images make it in (even though some should) What am I doing wrong? The other metadata filter seems to work (Cloudy pixel percentage).

var sentinel2 = ee.ImageCollection('COPERNICUS/S2')
.filterMetadata("SOLAR_IRRADIANCE_B4","less_than", 2000)

// Create an image time series chart.
var chart = ui.Chart.image.series({
  imageCollection: sentinel2,
  region: Caselton,
  reducer: ee.Reducer.mean(),
  scale: 200

// Add the chart to the map.
  position: 'bottom-right',
  width: '500px',
  height: '300px'

// Outline and center Either Pond
var caselton = ui.Map.Layer(Caselton, {color: 'FF0000'}, 'CMT');
Map.setCenter(-114.49052095413208,37.903421736152076, 15);

// Create a label on the map.
var label = ui.Label('Click a point on the chart to show the image for that 

// When the chart is clicked, update the map and label.
chart.onClick(function(xValue, yValue, seriesName) {
  if (!xValue) return;  // Selection was cleared.

  // Show the image for the clicked date.
  var equalDate = ee.Filter.equals('system:time_start', xValue);
  var image = ee.Image(sentinel2.filter(equalDate).first());
  var s2Layer = ui.Map.Layer(image, {
    gamma: 1.3,
    min: 0,
    max: 2500,
    bands: ['B4','B3','B2']
  Map.layers().reset([s2Layer, caselton]);

  // Show a label with the date on the map.
  label.setValue((new Date(xValue)).toUTCString());
  • You should use collection.filter(ee.Filter.lt()). i.e. don't use filterMetadata(). Don't think that's the solution to your problem, though. – Nicholas Clinton Apr 18 '18 at 16:09
  • Yeah, I meant to be filtering TOA reflectance, so the values I was using didn't make sense. The solution ended up being to add a property of the mean band value in my area of interest for each image in the collection, then filter on that. Thanks! – spizwhiz Apr 20 '18 at 20:24

Your Answer

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

Browse other questions tagged or ask your own question.