-1

Does anyone know how can I get GLDAS precipitation monthly 1 km resolution data by Earth-engine? Or maybe Earth-engine just process annual precipitation data by 0.25 degrees GLDAS product? Where is an example of related code?

2
  • If you type GLDAS in your search bar in earth engine, you get this choice of data sets. ![enter image description here](i.sstatic.net/teT6w.png) Are these the ones you mean? Commented Mar 13, 2020 at 14:22
  • No, not actually. I'm looking for a GLDAS monthly precipitation dataset, but I couldn't get the downloadable images. it gives me features collection instead of defined images
    – Maryam
    Commented Mar 16, 2020 at 8:17

1 Answer 1

4

For GLDAS precipitation monthly you could use 'Rainf_f_tavg' or 'Rainf_tavg' bands from 3 hourly "NASA/GLDAS/V20/NOAH/G025/T3H" product (resolution of 0.25 arc degrees). It would produce 8 daily values for these climatic elements. However, it is demanding very time processing so, you need to process a small time series for daily (2-5 years) or monthly values (1-2 years). For monthly aggregation, following script works but, in my system, CSV file was exported to my Google Drive in 21 min for one year (1984) and in 30 min for two years (1984-1985).

// Set years and month
var startYear = 1984;
var endYear = 1984;
var years = ee.List.sequence(startYear, endYear);
var months = ee.List.sequence(1,12);
// load the image collection
var Daily = ee.ImageCollection("NASA/GLDAS/V20/NOAH/G025/T3H")
                               //.select('Rainf_tavg');
                               .select('Rainf_f_tavg');

print(Daily.first());

var fg_points = ee.Geometry.Point(-70.2166985,-38.5275513); //p18

// make monthly mean 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 maxImage = yearCollection.filter(ee.Filter.calendarRange(m, m, 'month'))
        .reduce(ee.Reducer.mean()); 
      var date = ee.Date.fromYMD(y, m, 1).format("MM_dd_YYYY");
      return maxImage.set('system:time_start', ee.Date.fromYMD(y, m, 1)).rename(date);
      //.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();

var features = outputMonthly.reduceRegions(fg_points, ee.Reducer.first(), 30);
//print(features);

Map.centerObject(fg_points, 6);
Map.addLayer(fg_points);

Export.table.toDrive(features,
"Total_precipitation_rate_monthly",
"GEE_Folder",
"Total_precipitation_rate_monthly_p18");

Result (CSV file) obtained in my drive for 1984 (after it was manipulated in LibreOffice Calc with Transpose Paste Special option), it was as follows:

0_0_01_01_1984,2.48911283051711E-06
0_1_02_01_1984,4.36379286838928E-06
0_2_03_01_1984,7.05322554495069E-06
0_3_04_01_1984,9.18583282327745E-06
0_4_05_01_1984,3.10322575387545E-05
0_5_06_01_1984,2.83904173556948E-05
0_6_07_01_1984,2.08395158551866E-05
0_7_08_01_1984,6.88306454321719E-06
0_8_09_01_1984,1.36387498059776E-05
0_9_10_01_1984,1.00834677141393E-05
0_10_11_01_1984,5.48208345207968E-06
0_11_12_01_1984,3.92016136174789E-06

Above monthly precipitation values are in kg/m^2/s. Conversion factor to mm is 3600s*24*h*months_days, resulting in:

0_0_01_01_1984,6.66683980525704
0_1_02_01_1984,10.9339194110362
0_2_03_01_1984,18.8913592995959
0_3_04_01_1984,23.8096786779352
0_4_05_01_1984,83.1167985918
0_5_06_01_1984,73.587961785961
0_6_07_01_1984,55.8165592665319
0_7_08_01_1984,18.4356000725529
0_8_09_01_1984,35.3516394970939
0_9_10_01_1984,27.0075599255506
0_10_11_01_1984,14.2095603077905
0_11_12_01_1984,10.4997601913055

Previous values of precipitation in mm are comparable to those obtained with CHIRPS Daily series for 1984 in same point.

jan,17.6 
feb,9.7 
mar,15.3 
apr,9.1 
may,45.599999999999994 
jun,61.29999999999998 
jul,41.20000000000001
aug,15.4
sep,18.299999999999997 
oct,16.1
nov,10.8  
dec,15.500000000000004 

Editing Note:

Based in the answer of this question, I solved the issue of processing time. Next script processes, in a few minutes, a time series as long as 10 years because it only considers 3653 daily values instead 29224. Further, it also determines precipitation directly in mm instead kg/m^2/s:

var startDate = ee.Date('1984-01-01');
var endDate = ee.Date('1994-01-01');
var startYear = startDate.get('year');
var endYear = endDate.get('year');

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

var lst = ee.ImageCollection("NASA/GLDAS/V20/NOAH/G025/T3H")
  .select('Rainf_f_tavg')
  .filterDate(startDate, endDate);

var fg_points = ee.Geometry.Point(-70.2166985,-38.5275513); //p18

print(lst.size());

var days = endDate.difference(startDate, 'days');
var daysStep = 1;
var timeSeries = ee.ImageCollection(
  ee.List.sequence(0, days.subtract(1), daysStep)
    .map(function (offsetDays) {
      var start = startDate.advance(offsetDays, 'days');
      var end = start.advance(daysStep, 'days');
      var composite = lst
        .filterDate(start, end)
        .median(); // You need to decide how to combine the images
      return composite
        .set('system:time_start', start.millis())
        .set('empty', composite.bandNames().size().eq(0));
    })
  ).filterMetadata('empty', 'equals', 0);

print(timeSeries.size());

var transformed = timeSeries.map(function (image) {
  var date = image.get('system:time_start');
  var img = image.multiply(86400).set('system:time_start', date);
  return img;
});

//print(transformed);

// make monthly mean mosaics
// loop over the years and months to get summed monthly images
var byMonth = ee.ImageCollection(ee.FeatureCollection(years.map(function(y){
  var yearCollection = transformed.filter(ee.Filter.calendarRange(y, y, 'year'));
  var byYear = ee.ImageCollection.fromImages(
    months.map(function(m) {
      var maxImage = yearCollection.filter(ee.Filter.calendarRange(m, m, 'month'))
        .reduce(ee.Reducer.sum()); 
      var date = ee.Date.fromYMD(y, m, 1).format("MM_dd_YYYY");
      return maxImage.set('system:time_start', ee.Date.fromYMD(y, m, 1)).rename(date);
      //.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();

var features = outputMonthly.reduceRegions(fg_points, ee.Reducer.first(), 30);
//print(features);

Map.centerObject(fg_points, 6);
Map.addLayer(fg_points);

Export.table.toDrive(features,
"Total_precipitation_rate_monthly",
"GEE_Folder",
"Total_precipitation_rate_monthly_p18_def");

Resulting CVS file is, in this case, as follows:

0_0_01_01_1984,3.86640003198409
0_10_11_01_1984,13.4006398453494
0_11_12_01_1984,5.02847991265298
0_1_02_01_1984,6.43679998497646
0_2_03_01_1984,9.51695997646311
0_3_04_01_1984,18.9043195554405
0_4_05_01_1984,76.9176003042958
0_5_06_01_1984,63.19727924581
0_6_07_01_1984,39.152160309277
0_7_08_01_1984,15.5519993056942
0_8_09_01_1984,14.670719959031
0_9_10_01_1984,25.0430401499216
1_0_01_01_1985,9.89279989153147
1_10_11_01_1985,21.1420803680085
1_11_12_01_1985,4.37184003021685
1_1_02_01_1985,10.488959873328
1_2_03_01_1985,5.34383998601697
1_3_04_01_1985,13.3271997493353
1_4_05_01_1985,53.0755190909986
1_5_06_01_1985,22.4423995166717
1_6_07_01_1985,33.8169604921859
1_7_08_01_1985,7.00271979912941
1_8_09_01_1985,15.7161598355742
1_9_10_01_1985,29.2204801953631
2_0_01_01_1986,14.9688003526535
2_10_11_01_1986,22.723199952452
2_11_12_01_1986,7.77599990669842
2_1_02_01_1986,5.76720015794763
2_2_03_01_1986,5.42591985959007
2_3_04_01_1986,6.75648013911996
2_4_05_01_1986,68.6534396057823
2_5_06_01_1986,46.1073596790357
2_6_07_01_1986,20.7403199142391
2_7_08_01_1986,43.9171201184763
2_8_09_01_1986,5.1796800129523
2_9_10_01_1986,6.98543983453419
3_0_01_01_1987,0.198720000480535
3_10_11_01_1987,3.19248004743713
3_11_12_01_1987,7.82352009173337
3_1_02_01_1987,1.90944003459208
3_2_03_01_1987,21.5870400886615
3_3_04_01_1987,3.92256000593534
3_4_05_01_1987,18.2433600575678
3_5_06_01_1987,48.323519063706
3_6_07_01_1987,41.2732795706688
3_7_08_01_1987,50.5958402391912
3_8_09_01_1987,22.3559995988467
3_9_10_01_1987,21.928319962808
4_0_01_01_1988,1.01951993026432
4_10_11_01_1988,0.190080003449111
4_11_12_01_1988,4.94207999145146
4_1_02_01_1988,0.794879998545639
4_2_03_01_1988,9.12815977853825
4_3_04_01_1988,0.630720009212382
4_4_05_01_1988,7.38720007097982
4_5_06_01_1988,47.1830393106757
4_6_07_01_1988,6.89040005688639
4_7_08_01_1988,39.432959142141
4_8_09_01_1988,3.43008000969576
4_9_10_01_1988,4.77359992655693
5_0_01_01_1989,2.35871994591434
5_10_11_01_1989,3.44735987146123
5_11_12_01_1989,9.25343997982964
5_1_02_01_1989,0.414720014669001
5_2_03_01_1989,1.52928005225021
5_3_04_01_1989,1.66752001641726
5_4_05_01_1989,20.2392007353183
5_5_06_01_1989,51.5808003019629
5_6_07_01_1989,29.2334395671787
5_7_08_01_1989,39.3206411157735
5_8_09_01_1989,0.799199995526578
5_9_10_01_1989,0.224640007843391
6_0_01_01_1990,0.647999983630143
6_10_11_01_1990,4.00895987618242
6_11_12_01_1990,6.79967982468952
6_1_02_01_1990,6.53615985752367
6_2_03_01_1990,11.551679832337
6_3_04_01_1990,6.44112019958811
6_4_05_01_1990,16.0401592788617
6_5_06_01_1990,26.5420809781062
6_6_07_01_1990,1.37376003262943
6_7_08_01_1990,21.9931198871336
6_8_09_01_1990,17.0985602348082
6_9_10_01_1990,1.41696000428055
7_0_01_01_1991,2.71296005503245
7_10_11_01_1991,9.51695991752786
7_11_12_01_1991,17.4139196402393
7_1_02_01_1991,0.535679992754012
7_2_03_01_1991,2.77775995418779
7_3_04_01_1991,19.6646395299467
7_4_05_01_1991,50.025601090465
7_5_06_01_1991,28.1836801341342
7_6_07_01_1991,36.6465605464327
7_7_08_01_1991,32.4432002962567
7_8_09_01_1991,3.90096003484359
7_9_10_01_1991,23.6563197362102
8_0_01_01_1992,0.060479998865048
8_10_11_01_1992,11.4480001037009
8_11_12_01_1992,14.6188796526985
8_1_02_01_1992,5.93567997420905
8_2_03_01_1992,5.71536022180226
8_3_04_01_1992,18.5500800798764
8_4_05_01_1992,66.074399187346
8_5_06_01_1992,53.5723220782529
8_6_07_01_1992,34.041599565353
8_7_08_01_1992,23.0558403243776
8_8_09_01_1992,8.28143987853309
8_9_10_01_1992,17.3448000568897
9_0_01_01_1993,1.87919985037297
9_10_11_01_1993,22.0492798893247
9_11_12_01_1993,12.7051203878978
9_1_02_01_1993,0.25056000231416
9_2_03_01_1993,9.06767991473316
9_3_04_01_1993,14.2430398137549
9_4_05_01_1993,59.3870404438349
9_5_06_01_1993,54.9935999004447
9_6_07_01_1993,34.0891196030498
9_7_08_01_1993,24.3820797486819
9_8_09_01_1993,4.7390400599852
9_9_10_01_1993,30.4776002459675
5
  • thank you so much, you did me a favor. Earth engine shows feature collection of my data instead of image collection. what should I do?
    – Maryam
    Commented Mar 16, 2020 at 23:09
  • Your question was answered in my Editing Note. You only need to change coordinates values of point in fg_points for your point coordinates (perhaps dates if you desire a more long range) and to run the script. In your Google Drive you will have a CVS with precipitation values in mm per month and per year.
    – xunilk
    Commented Mar 17, 2020 at 0:20
  • You need to run the task in Tasks Tab. You also need to create GEE,_Folder in Google Drive.
    – xunilk
    Commented Mar 18, 2020 at 17:01
  • Dear friend, after runnig codes, it calculates numbers in console: 5840, 730 respectfully for a year-period 2009-2019. The CVS file contains just 1 row with 25 columns (only for 2010). Would you please tell me that is it a complete sheet of data for 10 years period? How does it work?
    – Maryam
    Commented Mar 18, 2020 at 19:53
  • There are two rows, not one. So, you need to use a software as Excel to read CVS file and convert it in two columns table with transpose option. At this point, you will see monthly precipitation ids and its respective values. For 10 years there are 120 values. If you see 25 is because only was calculated for 2 years (24 months). Last column represents geometry and it must be eliminated.
    – xunilk
    Commented Mar 18, 2020 at 20:15

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.