0

i need run this code in my nodeJS application:

//Dates of Interest
var start = ee.Date("2014-10-01");
var finish = ee.Date("2018-05-01");

///--------------------- Landsat Collection ---------------------------------------///
var landsat = ee.ImageCollection('LANDSAT/LC08/C01/T1_TOA')
.filterDate(start, finish)
.filterBounds(roi);

// Year-Month-Day Extract function
function ymdList(imgcol){
    var iter_func = function(image, newlist){
        var date = ee.Number.parse(image.date().format("YYYYMMdd"));
        newlist = ee.List(newlist);
        return ee.List(newlist.add(date).sort())
    };
    return imgcol.iterate(iter_func, ee.List([]));
}

var ymd = ymdList(landsat);
print(ee.List(ymd).reduce(ee.Reducer.frequencyHistogram()));

But I do not know which function to use in place of "print ()", can anyone help me?

2

The typical way of logging a value in nodejs is console.log( myValue ). To evaluate a variable that hasn’t been computed yet, which the Earth Engine code editor does automatically when you print, you may want to define your own print function instead:

var print = function (o) {
  if (o instanceof ee.ComputedObject) {
    o = o.getInfo();
  }
  console.log(o);
};

Your Answer

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

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