1

I need to filter out all images of a ee.imageCollection that is not complete (does not cover the entire geometry). I tried using .filterMetadata('MGRS_TILE') and I didn't make it. Any idea?

enter image description here

Here is my script: Google Earth Engine Script

var perimeter = ee.FeatureCollection(table);

var start = '2019-03-16'
var end = '2019-03-25'

var tiles = ['T20JML', 'T20JML']
var dataset = ee.ImageCollection('COPERNICUS/S2_SR').filterMetadata('MGRS_TILE', 'equals', '20JML')
                  .filterBounds(perimeter)
                  .filterDate(start, end)
                  .filterMetadata('CLOUDY_PIXEL_PERCENTAGE', 'less_than', 10);
print(dataset)
var ultima = dataset.first()

var imagen = ee.Image(ultima).normalizedDifference(['B8', 'B4'])

var minMax = imagen.reduceRegion({reducer: ee.Reducer.minMax(), 
                               geometry: perimeter})

var minMax = minMax.rename(minMax.keys(), ['max','min']);  

minMax.evaluate(function(val){
  var min = val.min;
  var max = val.max;

var visParam = {
        min: min,
        max: max,
        palette: ['FFFFFF', 'CE7E45', 'DF923D', 'F1B555', 'FCD163', '99B718', '74A901',
    '66A000', '529400', '3E8601', '207401', '056201', '004C00', '023B01',
    '012E01', '011D01', '011301']
        };
        
Map.addLayer(imagen.clip(perimeter), visParam, "Imagen Ultimo NDVI");
Map.setOptions('SATELLITE')
Map.centerObject(perimeter, 16)
Map.addLayer(perimeter, {}, "Perimetro Lote");

  
})
1
  • I don't think you can remove these images from the image collection as your perimeter is actually contained within the footprint of the scene. So from the collection filtering point-of-view, all is good, even if you would use an ee.Filter.isContained() filter. But you do have these masked pixels close by the boundary. See here: code.earthengine.google.com/2b73c1a1ec0ef3784ffdf575fe113e62 Nov 30, 2022 at 14:16

1 Answer 1

0

There are no other images with the characteristics you need (date range and cloud cover).

An option is to extend the date range to get the first image of the month, which covers your geometry.

var perimeter = ee.FeatureCollection(table);
var start = '2019-03-01'
var end = '2019-03-31'

var tiles = ['T20JML', 'T20JML']
var dataset = ee.ImageCollection('COPERNICUS/S2_SR')
                  .filterBounds(perimeter)
                  .filterDate(start, end)
                  .filterMetadata('CLOUDY_PIXEL_PERCENTAGE', 'less_than', 10)

var ultima = dataset.first()

var imagen = ee.Image(ultima).normalizedDifference(['B8', 'B4'])

var minMax = imagen.reduceRegion({reducer: ee.Reducer.minMax(), 
                               geometry: perimeter})

var minMax = minMax.rename(minMax.keys(), ['max','min']);  

minMax.evaluate(function(val){
  var min = val.min;
  var max = val.max;

var visParam = {
        min: min,
        max: max,
        palette: ['FFFFFF', 'CE7E45', 'DF923D', 'F1B555', 'FCD163', '99B718', '74A901',
    '66A000', '529400', '3E8601', '207401', '056201', '004C00', '023B01',
    '012E01', '011D01', '011301']
        };
        
Map.addLayer(imagen.clip(perimeter), visParam, "Imagen Ultimo NDVI");
Map.setOptions('SATELLITE')
Map.centerObject(perimeter, 16)
Map.addLayer(perimeter, {}, "Perimetro Lote");


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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