I have calculated the monthly total rainfall for a region using CHIRPS data and would like to add this data onto a graph. At the moment it works for one single year, when I set "month" as the xProperty. However, when I sum the images by month in this function below, the system:time_start
variable is lost, meaning I cannot add images from multiple years to a graph whilst showing the date correctly along the x-axis. I believe I need to copy over the system:time_start
variable from the first image of the month to the summed image in this function but I am not sure how to do this.
var lt_precip = ee.ImageCollection.fromImages(
years.map(function (y) {
return months.map(function (m) {
return precipitation.filter(ee.Filter.calendarRange(y, y, 'year'))
.filter(ee.Filter.calendarRange(m, m, 'month'))
.sum()
.set('year', y)
.set('month', m)
});
}).flatten());
print("lt_precip",lt_precip);
Please find a full link to the code here: https://code.earthengine.google.com/43c0eebd26ac7a22c33f7a6ef2160ee4.