0

I'm using GSMaP image collection in Google Earth Engine, which has hourly precipitation data from 2000 to present. I have a script which helps getting data (as a table) from points from each available image in given period. Could anyone please assist me on how to make the function that it will sum the values of hourly data to daily. Please, find the script which should be improved below:

 //Points
var p1 = /* color: #d63000 */ee.Geometry.Point([69.15, 54.8331]),
    p2 = /* color: #98ff00 */ee.Geometry.Point([70.917, 54.433]),
    p3 = /* color: #0b4a8b */ee.Geometry.Point([66.967, 54.367]);

    // Collection of point
    var pts = ee.FeatureCollection(ee.List([ee.Feature(p1),ee.Feature(p2), ee.Feature(p3)]))

    // Import GSMaP data
    var gsmap = ee.ImageCollection('JAXA/GPM_L3/GSMaP/v6/reanalysis')
    .filterDate(ee.Date.fromYMD(2014,1,1), ee.Date.fromYMD(2015,1,1))
    .select('hourlyPrecipRateGC');

    // Empty Collection to fill
    var ft = ee.FeatureCollection(ee.List([]))

    var fill = function(img, ini) {
      // type cast
      var inift = ee.FeatureCollection(ini)

      // gets the values for the points in the current img
      var ft2 = img.reduceRegions(pts, ee.Reducer.first(),30)

      // gets the date of the img
      var date = img.date().format()

      // writes the date in each feature
      var ft3 = ft2.map(function(f){return f.set("date", date)})

      // merges the FeatureCollections
      return inift.merge(ft3)
    }

    // Iterates over the ImageCollection
    var newft = ee.FeatureCollection(gsmap.iterate(fill, ft))

    // Export
    Export.table.toDrive(newft,
    "KZ_GSMaP_14-15",
    "KZ_GSMaP_point data",
    "KZ_GSMaP_14-15")

marked as duplicate by Kersten, whyzar, Vince, tinlyx, BERA May 7 '18 at 5:45

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

3

This would be my approach:

note: enddate is modified so it doesn't take to long to process. Modify it to your needs.

var p1 = /* color: #d63000 */ee.Geometry.Point([69.15, 54.8331]),
    p2 = /* color: #98ff00 */ee.Geometry.Point([70.917, 54.433]),
    p3 = /* color: #0b4a8b */ee.Geometry.Point([66.967, 54.367]);

// Collection of point
var pts = ee.FeatureCollection(ee.List([ee.Feature(p1),ee.Feature(p2), ee.Feature(p3)]))

// Start and End Dates
var inidate = ee.Date.fromYMD(2014,1,1)
var enddate = ee.Date.fromYMD(2014,3,1)

// Difference between start and end in days 
var difdate = enddate.difference(inidate, 'day')

// Import GSMaP data
var gsmap = ee.ImageCollection('JAXA/GPM_L3/GSMaP/v6/reanalysis')
.filterDate(inidate, enddate)
.select('hourlyPrecipRateGC');

// Time lapse
var lapse = ee.List.sequence(0, difdate.subtract(1))
var inidate = ee.Date('2014-01-01')
var listdates = lapse.map(function(day){
  return inidate.advance(day, 'day')
})

// Iterate over the list of dates
var newft = ee.FeatureCollection(listdates.iterate(function(day, ft) {
  // Cast
  ft = ee.FeatureCollection(ft)
  day = ee.Date(day)

  // Filter the collection in one day (24 images)
  var day_collection = gsmap.filterDate(day, day.advance(1, 'day'))

  // Get the sum of all 24 images into one Image
  var sum = ee.Image(day_collection.sum())

  // map over the ft to set a property over each feature
  var temp_ft = ft.map(function(feat){
    var geom = feat.geometry()
    var value = sum.reduceRegion(ee.Reducer.first(), geom, 30).get('hourlyPrecipRateGC')
    return feat.set(day.format('YYYY-MM-dd'), value)
  })

  // Return the FeatureCollection with the new properties set
  return temp_ft
}, pts))

print(newft)

// Export
Export.table.toDrive(newft,
"KZ_GSMaP_14-15",
"KZ_GSMaP_point data",
"KZ_GSMaP_14-15")
  • Dear Rodrigo E. Principe, thank you very much for your suggestion. It worked perfectly. – Sarvarbek Eltazarov May 3 '18 at 14:47
  • Your are welcome! If it is what you needed, please mark it as the correct answer – Rodrigo E. Principe May 3 '18 at 14:49
  • Dear Rodrigo, I asked one more question in this portal which is similar to above question. But there I need to get mean pcp data for polygon. I would highly appreciate if you could help me to improve the script!!! – Sarvarbek Eltazarov May 3 '18 at 15:51
  • The topic of the question is "Reduce image collection to get daily sum from hourly precipitation and extraction of polygon data". – Sarvarbek Eltazarov May 3 '18 at 16:03
  • Dear Rodrigo, I would like to improve the above script by adding calculation of max, min and median of polygons. Can you please, check is below improvement is correct? var mean = sum.reduceRegion(ee.Reducer.mean(), geom, 10000).get('hourlyPrecipRateGC') var max = sum.reduceRegion(ee.Reducer.max(), geom, 10000).get('hourlyPrecipRateGC') var min = sum.reduceRegion(ee.Reducer.min(), geom, 10000).get('hourlyPrecipRateGC') var med = sum.reduceRegion(ee.Reducer.median(), geom, 10000).get('hourlyPrecipRateGC') return feat.set(day.format('YYYY-MM-dd'), (mean, max, min, med)) – Sarvarbek Eltazarov Nov 13 '18 at 15:57

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