I want to cumulate the daily precipitation in Google Earth Engine, in a ROI and over a prescribed time period, provided by "CHIRPS Daily" to obtain a chart like the one in the figure 1 (with a time step of 1 day).
Do you have any suggestion? Thank you in advance :)
Here is the code of CHIRPS daily precipitation Chart
// Select Dates
var startDate = '2021-06-01'
var endDate = '2021-09-01'
// Select Band (precipitation in case of CHIRPS dataset)
var selected_band = 'precipitation'
// create an Image collection
var dataset = ee.ImageCollection('UCSB-CHG/CHIRPS/DAILY')
.filterBounds(Sonipat)
.filter(ee.Filter.date(startDate, endDate))
.select(selected_band)
// Check the count of days for which you want to extract the data
var count = dataset.size();
print("image collection count between selected dates is :", count);
// check the Cumulative rainfall of the region of interest during that period
// an Image will also be displayed which will confirm your Area of Interest
var cumulativeRainfallImage = dataset.sum().clip(Sonipat);
print(cumulativeRainfallImage );
var precipitationVis = {
min: 1.0,
max: 17.0,
palette: ['001137', '0aab1e', 'e7eb05', 'ff4a2d', 'e90000'],
};
Map.setCenter(76, 30, 7);
Map.addLayer(cumulativeRainfallImage , precipitationVis, 'Precipitation');
// Set some Vector Properties to see your shapefile/vector layer
var shown = true; // true or false, 1 or 0
var opacity = 0.8; // number [0-1]
var nameLayer = 'Sonipat'; // string
var visParams = {color: 'Black'}; // dictionary:
Map.addLayer(Sonipat, visParams, nameLayer, shown, opacity);
// Define the chart properties and see the output in the console.
var chart =
ui.Chart.image
.seriesByRegion({
imageCollection: dataset,
band: selected_band,
regions: Sonipat,
reducer: ee.Reducer.mean(),
scale: 5000,
seriesProperty: 'DISTRICT',
xProperty: 'system:time_start'
})
.setOptions({
title: 'Daily CHIRPS Rainfall',
hAxis: {title: 'Date', titleTextStyle: {italic: false, bold: true}},
vAxis: {
title: 'Rainfall (mm)',
titleTextStyle: {italic: false, bold: true}
},
lineWidth: 5,
colors: ['CE7E45'],
});
print(chart);
The image will generate in the right panel of console,
and after hitting the arrow icon on upper right corner,
you will be redirected to another window, where you can download the CSV, and cumulate later,