Geographic Information Systems Asked on March 11, 2021
I am still new to the Google Earth Engine and try to calculate the daily precipitation based on the hourly GSMaP data over a longer period of time. I know, that there are already a couple of questions about that topic, so I put an eye on this and this. However, as I need to calculate the daily precipitation over several years, I use a list of Dates. It seems to work in general, but the first image of the image collection is always empty and it seems like, the daily sum of the precipitation data for the other images is not calculated properly. When I compare my results with the GSMaP webmap, my image seems not to cover all raining events of that day. Has somebody an idea why the first image has no band and the rest might not be calculated correctly?
//Add Dates
var iniDate = ee.Date('2019-05-01')
var endDate = ee.Date('2020-05-19')
//Add ImageCollection
var filterGSMAP = GSMAP.filterDate(iniDate, endDate).select(['hourlyPrecipRateGC']);
//print(filterGSMAP)
var difdate = endDate.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
var gsmapImageCollection = ee.ImageCollection.fromImages(listdates.map(function(summarize_day){
var year = ee.Date(summarize_day).get('year'); //get the year of the list entry
var doy = ee.Date(summarize_day).getRelative('day', 'year'); //get the "day of year" of list entry
var filteredYear = filterGSMAP.filter(ee.Filter.calendarRange({ //filter the Image collection for the year
start: year,
field: 'year'
}));
var filterDay = filteredYear.filter(ee.Filter.calendarRange({ //filter the Image Collection for DOY
start: doy,
field: 'day_of_year'
}));
var currentDate = ee.Date(summarize_day)
return filterDay.sum().copyProperties(filterDay).setMulti({
Date: currentDate
});
}))
print(gsmapImageCollection)
Map.addLayer(filterGSMAP.first(), GSMAPvis, 'GSMap');
First, check the date range of the image collection you are using in the properties. You will find out that the last day available at the time writing in 17 May 2020:
//Add Dates
var iniDate = ee.Date('2019-05-01')
var endDate = ee.Date(ee.List(GSMAP.get('date_range')).get(1)) // last date is currently 2020-05-17
Then 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');
var createList = ee.List.sequence(0, difdate)
var listdates = createList.map(function(day){
return iniDate.advance(day, 'day')
})
Then filter the image collection using the filterDate
, which is (I think) easier than filtering on year and doy consecutively:
//Summarize hourly precipitation data to daily precipitation data
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().copyProperties(filterCol.first()).setMulti({
Date: ee.Date(summarize_day), 'system:time_start': ee.Date(summarize_day).millis()
});
}))
I would always recommend to set a system:time_start
property, so you can easily plot/filter etc the resulting image collection. Don't forget to add the resulting image collection to the map: Link code
Correct answer by Kuik on March 11, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP