4

I want to get daily precipitation data instead of 3-hourly data from TRMM in earth engine. How can I reduce it to daily precipitation data?

The following code is to get 3-hourly precipitation from TRMM over a feature collection of 19 points:

https://code.earthengine.google.com/b71d1fa3beb03f9254480882d5b354c2

var pcp = trmm.select('precipitation').filterDate('2000-01-01','2004-01-01');

print(bait.select([]));
bait.select([]).evaluate(function (featureCollection) 
{
  featureCollection.features.forEach(function (feature) 
  {
    print(ui.Chart.image.series(
    pcp.limit(5000),ee.Geometry(feature.geometry),ee.Reducer.mean(),1000).setOptions({
  title: 'Precipitation time series ' + feature.id + ' ('+ feature.geometry.coordinates+')',
  hAxis: {title: 'Year'},
  vAxis:{title:'mm/hr'}
 }));
 });
});

Map.addLayer(bait);
Map.centerObject(bait);
2

The trick is to iteratively filter your original collection by each day in the date range of interest and reduce the constituents. You can do this by making a day sequence List and mapping over it and advancing the start and end dates of the filterDate filter by the enumerated day. An image list is returned, which can be converted to an ImageCollection. Here is the snippet that does the daily compositing:

// Enumerate a list of days.
var daysList = ee.List.sequence(0, nDays.subtract(1));

// Map over the list of days to make daily sum composites.
var pcpDayList = daysList.map(function(dayN){
  var t1 = startDate.advance(ee.Number(dayN), 'day');
  var t2 = t1.advance(1, 'day');
  var dailySum = pcp.filterDate(t1, t2).sum();
  var nBands = dailySum.bandNames().size();
  return dailySum
    .set({
      'system:time_start': t1.millis(),
      'nBands': nBands
    });
});

You'll have to decide how to reduce the daily collection. Here I used sum(). I edited the script to implement the above compositing method. Note that I changed the number of days to chart and the scale (so it would plot). If you are going to plot all of the years you may need to do a region reduction outside of the chart and export the result as an asset and then read in the asset and chart it. With all of the compositing that needs to happen, the operation in the browser will likely time out.

https://code.earthengine.google.com/ece3c36bf5706fd237353c71d14623ad

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.