0

I would like to get the CSV file of rain daily data from GSMAP for a specified polygon (mean in geometry).

I succeed in getting into it on a chart, but now I want to download the data and I'm having some trouble

Could you help me?

//Add Dates range, with las date available
var iniDate = ee.Date('2018-03-01')
var endDate = ee.Date(ee.List(GSMAP.get('date_range')).get(1)) //last date 

print('lastDay available', ee.Date(ee.List(GSMAP.get('date_range')).get(1)))

//Add ImageCollection
var filterGSMAP = GSMAP.filterDate(iniDate, endDate).select(['hourlyPrecipRateGC']);

//Initiate the date list with a day less than the availability, 
//as the last day available does not contain images:
var difdate = endDate.advance(-1, 'day').difference(iniDate, 'day'); //calculate steps/days in between
var createList = ee.List.sequence(0, difdate) //make list with the needed number of entries
var listdates = createList.map(function(day){ //change list into list of dates
return iniDate.advance(day, 'day')})
print(listdates)

//Summarize hourly precipitation data to daily precipitation data
//Then filter the image collection using the filterDate, which is (I think) easier than filtering 
//on year and doy consecutively:
var gsmapImageCollection  = ee.ImageCollection.fromImages(listdates.map(function(summarize_day){
var filterCol = filterGSMAP.filterDate(ee.Date(summarize_day), ee.Date(summarize_day).advance(1, 'day'))
return filterCol.sum().select(['hourlyPrecipRateGC'], ['dailyPrecipRateGC'])
.copyProperties(filterCol.first()).setMulti({
Date: ee.Date(summarize_day), 'system:time_start': ee.Date(summarize_day).millis()});}))
print(gsmapImageCollection)
print(ui.Chart.image.series(gsmapImageCollection, geometry, ee.Reducer.mean(), 5000)
.setChartType('ColumnChart'));

//Set a system:time_start property,
//so you can easily plot/filter etc the resulting image collection.
//Add the resulting image collection to the map
var VIS = {palette: ['1621a2','ffffff', '03ffff','13ff03','efff00','ffb103', 'ff2300'], min: 0, max: 50}
//Map.addLayer(gsmapImageCollection.first(), VIS, 'GSMap');

// Here is my doubt, how can i get the CSV file with two columns, day and acumulated rain.
//Export the time-series as a csv.
Export.table.toDrive({
  collection: gsmapImageCollection, 
  description: 'rain', 
  selectors: 'day, value', 
  fileFormat: 'CSV'
});

1 Answer 1

1
var Elv = ee.Geometry.Point(96.13322,16.90731);
Map.addLayer(Elv, {}, 'Yangon_INT')

// load in data and select dates 
var PRECIP = ee.ImageCollection("JAXA/GPM_L3/GSMaP/v6/operational")   
                 .filterDate('2021-01-01','2021-12-31');

//print(PRECIP);

var getPrecipit = function(image) {
  
  var time = ee.Date(ee.Image(image).get('system:time_start')).format().slice(0, 10); 
  
  var value_precipt = ee.Image(image)
    .reduceRegion(ee.Reducer.first(), Elv)
    .get('hourlyPrecipRate');
  
  return [time, value_precipt];
  
};

var count = PRECIP.size();

print("Number of values", count);

var precipit_list = PRECIP.toList(count).map(getPrecipit);

//print(precipit_list);

var myFeatures = ee.FeatureCollection(precipit_list.map(function(el){
  el = ee.List(el); // cast every element of the list
  var geom = Elv;
  return ee.Feature(geom, {
    'date': ee.String(el.get(0)),
    'value':ee.Number(el.get(1))
  });
}));

//print(myFeatures);

// Export features, specifying corresponding names.
Export.table.toDrive(myFeatures,
"2021", //my task
"GEE_Folder", //my export folder
"2021",  //file name
"CSV");

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.