2

I am trying to make an area-averaged time series of daily precipitation (IMERG). I'd use NASA Giovanni, but I need to be able to use my own shapefiles to average the areas. Given the size of the area needed and length of time required, it makes sense to send the timeseries directly into my Drive as a CSV instead of plotting it in GEE.

How can I get the timeseries data from chart without plotting it in GEE first? This is what I got so far:

//gonna try and use imerg

//add polygon
//if you do this with mulitpile features it wont work
var geometry = ee.FeatureCollection(table)
Map.addLayer(geometry,{color:'green'},'Border');
Map.centerObject(geometry);


//get imerg
var imerg = ee.ImageCollection("NASA/GPM_L3/IMERG_V06") 
  // Filter to study period
  .filterDate('2021-01-01', '2021-01-10')
  // Filter to plot boundaries
  .filterBounds(geometry);


var precip = ui.Chart.image.seriesByRegion(
  imerg,                // Image collection
  geometry,      // Region
  ee.Reducer.mean(), // Type of reducer to apply
  'precipitationCal');            
                   
print(precip);

//it may be too big to make a chart here
//is it quicker to send it to a csv?

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

I can make an area averaged time series of a few days, but both the area and time need to be much larger.

1
  • 1
    Please ask one question and also don't post 'I don't know how', post 'this is what I have tried' or the question will be closed soon. You need to filter by day and then reduce images.
    – aldo_tapia
    Commented Jul 13, 2022 at 18:54

1 Answer 1

1

You can get the timeseries for daily data filtering by day. Inclusively, you can also plot the chart in GEE, however, you need a monthly aggregation because it can have a large amount of data (> 5000; limit in GEE). For a dates range between "2001-01-01" and "2022-12-31", following code looks as follows for an arbitrary area in Namibia (because your asset was not available).

var table = ee.Geometry.Polygon(
        [[[15.011233342458334, -23.5446045392341],
          [15.011233342458334, -23.56789330398866],
          [15.072859776784506, -23.56789330398866],
          [15.072859776784506, -23.5446045392341]]], null, false);

//gonna try and use imerg

//add polygon
//if you do this with mulitpile features it wont work
var geometry = ee.FeatureCollection(table);
Map.addLayer(geometry,{color:'green'},'Border');
Map.centerObject(geometry);

//SETUP DATES
var startYear = 2001;
var endYear = 2021;
var startDate = ee.Date.fromYMD(startYear, 01,01);
var endDate = ee.Date.fromYMD(endYear + 1, 12,31);

var dataset = ee.ImageCollection('NASA/GPM_L3/IMERG_V06')
  .filterDate(startDate, endDate)
  .select(['precipitationCal']); 

var nDays = ee.Number(endDate.difference(startDate,'day').round());

print(nDays);

var byDays = ee.ImageCollection(
  ee.List.sequence(0, nDays).map(function (n) {
    var ini = startDate.advance(n,'day');
    var end = ini.advance(1,'day');
    return dataset.filterDate(ini,end)
                .select(0).sum()
                .set('system:time_start', ini);
}));

print(byDays.limit(5000));

var months = ee.List.sequence(1,12);

var nMonths = ee.Number(endDate.difference(startDate,'month')).round();

var byMonth = ee.ImageCollection(
  ee.List.sequence(0, nMonths).map(function (n) {
    var ini = startDate.advance(n,'month');
    var end = ini.advance(1,'month');
    return dataset.filterDate(ini,end)
                .select(0).sum()
                .set('system:time_start', ini);
}));

print(byMonth);

var precip = ui.Chart.image.seriesByRegion(
  byMonth,                // Image collection
  geometry,      // Region
  ee.Reducer.mean(), // Type of reducer to apply
  'precipitationCal',
  11132);            
  
var plotprecip = precip;                  // Data
print(plotprecip);

After running it in GEE code editor, I got result of following picture. There are 8034 daily images in this dates range and, in the Console Tab, it was printed 5000 of these images. Chart reflects a monthly aggregation.

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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