Answering your other question about how to get one Image for each month:
// Set years and month
var startYear = 1981;
var endYear = 2019;
var years = ee.List.sequence(startYear, endYear);
var months = ee.List.sequence(1, 12);
// load the image collection
var Daily = ee.ImageCollection('MODIS/MOD13A1').select(1)
.filterBounds(YourBound);
print(Daily, "Daily prec data from 1981-2019")
// make monthly summed mosaics
// loop over the years and months to get summed monthly images
var byMonth = ee.ImageCollection(ee.FeatureCollection(years.map(function (y) {
var yearCollection = Daily.filter(ee.Filter.calendarRange(y, y, 'year'));
var byYear = ee.ImageCollection.fromImages(
months.map(function (m) {
var summedImage = yearCollection.filter(ee.Filter.calendarRange(m, m, 'month'))
.reduce(ee.Reducer.sum());
var date = ee.Date.fromYMD(y, m, 5).format("MM_dd_YYYY");
return summedImage.set('system:time_start', ee.Date.fromYMD(y, m, 5))
.rename(date)
.reduce(ee.Reducer.mean());
//.set('month', m).set('year', y); // eventually set year and month
}));
return byYear;
})).flatten());
// filter the empty one out
var outputMonthly = byMonth.filter(ee.Filter.listContains('system:band_names',
'constant').not())
.sort('system:time_start').toBands();
print(outputMonthly);
var features = outputMonthly.reduceRegions(YourBound, ee.Reducer.first(), 30);
print(features);
Export.image.toDrive({
image: features,
description: "CHIRPS_monthly_mean_1981-2019",
scale: 3000,
folder: "CHIRPS_months",
region: YourBound
});
ee.Filter.calendarRange(start,end,field)
you can select by month or year. But I don't know how to create a function to do this