1

I wanted to iterate a function taking year as an argument to get my desired Landsat collections per year. I'm concatenating argument 'yr' and iterating using .map function.

An _.concat is not a function error appears.

Any help is appreciated! Thanks!

-Nands

var per_year = function(yr){
    var start = '-01-01';
    var end = '-12-31';

    var collect = ee.ImageCollection("LANDSAT/LE07/C01/T1_RT_TOA")
     .filter(ee.String(yr).concat(start), ee.String(yr).concat(end));

    return (collect);
}

var years = ee.Array(ee.List.sequence(2006, 2012));
print (years);

var year_list = years.map(per_year(years));
Ryan M
  • 18,333
  • 31
  • 67
  • 74

1 Answers1

0

You will need to map over an ee.List object that has all of the years, call the Landsat image collection in the function, and cast the results to an image collection.

var landsat = ee.ImageCollection("LANDSAT/LE07/C01/T1_RT_TOA")
var years = ee.List.sequence(2013,2017)

var yearlyCollections = years.map(function(i){
    i = ee.Number(i)
    var date = ee.Date.fromYMD(i,1,1)
    return landsat.filterDate(date, date.advance(1,'year')
})

print(yearlyCollections)

The result should be a ee.List object with the same number of image collection as years.

Kel Markert
  • 807
  • 4
  • 12