0

I'm working on a google earth engine app. In order to let it run without code changing, i need to specify a date range to filter an ImageCollection. The inicial date should be an arbitrary one, but the last date should be the "latest" available. It would be nice also if anybody knows how to open a dialogue to let the user specify the inicial date.

var app = function (image)
    {
    //NDVI
    var ndvi = image.normalizedDifference(['B8', 'B4']);
    image = image.addBands(ndvi.rename('NDVI'));
    return image;
    }

var OLI = ee.ImageCollection("COPERNICUS/S2")
    .filterDate('2016-10-01','2019-01-29')
    .filterMetadata('CLOUDY_PIXEL_PERCENTAGE','less_than',10)
    //.map aplica la funcion "app" definida previamente a la ImageCollection
    .filterBounds(table)
    .map(app);
javier Moreira
  • 65
  • 2
  • 10
  • find the solution, `var today = new Date(); var dd = today.getDate(); var mm = today.getMonth() + 1; //January is 0! var yyyy = today.getFullYear(); if (dd < 10) { dd = '0' + dd; } if (mm < 10) { mm = '0' + mm; } today = yyyy + '-' + mm + '-' + dd; var OLI = ee.ImageCollection("COPERNICUS/S2") .filterDate('2016-10-01',today) .filterMetadata('CLOUDY_PIXEL_PERCENTAGE','less_than',10) //.map aplica la funcion "app" definida previamente a la ImageCollection .filterBounds(table) .map(app);` – javier Moreira Jan 30 '19 at 17:13
  • [https://stackoverflow.com/questions/1531093/how-do-i-get-the-current-date-in-javascript] – javier Moreira Jan 30 '19 at 17:19

0 Answers0