1

I am trying to adapt a script made available by colleagues from the GEE of the GSMaP image collection. The script obtains data (as a table) of the points of each image available in a given period and adds the hourly data per day. In my case, I want to compare this data (daily sum) with rain data that is collected from 12:00pm to 11:00am (Brazil). Therefore, you would need help for the script to add, for example, from 12:00pm 01/01/2019 to 11:00am 01/02/2019. Please find the script that needs to be improved below:

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")
1
  • * the formation of the image of accumulated daily precipitation starts with the search for the 12: 00 pm image of the day and ends with the 11: 00 am image of the subsequent day Apr 3 '20 at 18:13
0

You could define a list of start dates using the brazil GMT like this:

// Time lapse
var lapse = ee.List.sequence(0, difdate.subtract(1))
  // time zone Brazil (GMT-2, -3, -4 or -5)
                    // YYYY-MM-DDThh:mmTZD (eg 1997-07-16T19:20+01:00
var inidate = ee.Date('2014-01-01T12:00-03:00') 
var listdates = lapse.map(function(day){
          // start date 
  return inidate.advance(day, 'day');
})
print(listdates)

And then apply the same code (note that the end date is exclusive, thus adding one day (24hours) would be correct)

link code

2
  • Dear @Kuik, you solved my problem. Apr 5 '20 at 16:23
  • My script is giving a problem in featurecollection, when I run the code below. I don't know what it might be. The code is available at the link below. If you can help me, thank you. [link] (code.earthengine.google.com/…) Apr 6 '20 at 15:53

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.