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")