oogle Earth Engine (GEE) - time series data synthesis - yearly synthesis

First make a multi-year list year list (2018 - 2021, including 2018 and 2021), then loop through the list, and then use the mean method to calculate the data set of one year into a single image, while adding relevant Attribute, generate and return an image list, and finally call the initialization method of the image collection to generate the image collection (ImageCollection).

code

var roi = ee.FeatureCollection('users/dfvsdjhvdshvs/shandong').geometry();
Map.centerObject(roi, 7); 

var Sentinel2 = ee.ImageCollection("COPERNICUS/S2"); 

var start_year = 2018;  
var end_year = 2021;  
var yearList = ee.List.sequence(start_year, end_year);  
var yearImgList = yearList.map(function(year) {  
  year = ee.Number(year);  
  var tempCol = Sentinel2.filter(ee.Filter.calendarRange(year, year, "year"))  
                    .filterBounds(roi)  
                  
  var img = tempCol.mean();  
  img = img.set("year", year);  
  img = img.set("system:index", ee.String(year.toInt()));  
  return img;  
});  

var yearImgCol = ee.ImageCollection.fromImages(yearImgList);  
print("year image collection", yearImgCol);

exhibit

Guess you like

Origin blog.csdn.net/weixin_48048649/article/details/128994728