I would like to have a CSV file which contain a time-series of 30 minutes rainfall from last 10-days before Landslide occurs from certain (landslide) location. I used NASA GPM IMERG data for the rainfall, and try to write a GEE script (compiling from others too) as below:
// Define a point of interest as a landslide location.
var POI = ee.Geometry.Point(111.19165, -8.08875); // Adjust the coordinate
Map.centerObject(POI, 9);
// Date when landslide occurs
var lsevent = new Date('2017-11-29'); // Adjust date period with landslide event
var start = new Date(lsevent.getTime() - 10*24*60*60*1000); // 10-days before
var end = new Date(lsevent.getTime() + 1*24*60*60*1000); // 1-day after
print(start);
print(end);
// Import NASA GPM IMERG 30 minute data.
var imerg = ee.ImageCollection('NASA/GPM_L3/IMERG_V06');
var imergHH = imerg.filterBounds(POI)
.filterDate(start, end)
.select('precipitationCal');
// Add rainfall accumulation into map
var precip = imergHH.select('precipitationCal').sum();
// Rainfall vis parameter
var palette = [
'000096','0064ff', '00b4ff', '33db80', '9beb4a',
'ffeb00', 'ffb300', 'ff6400', 'eb1e00', 'af0000'
];
var precipVis = {min: 0.0, max: 1000.0, palette: palette, opacity:0.5};
Map.addLayer(precip, precipVis, "10-days rainfall", false);
Map.addLayer(POI, {palette:"#ff0000"}, "Landlside location", true);
// Create a function that takes an image, calculates the mean over a geometry and returns
// the value and the corresponding date as a feature.
var timeSeries = imergHH.map(function (image) {
var imergdate1 = image.date().format('yyyy-MM-dd-hh-mm');
var value = image
.clip(POI)
.reduceRegion({
reducer: ee.Reducer.mean(),
scale: 30
}).get('precipitationCal');
return ee.Feature(null, {value: value, date: imergdate1});
});
var accumulation = imergHH.map(function (image) {
var imergdate2 = image.date().format('yyyy-MM-dd-hh-mm');
var value = image
.clip(POI)
.reduceRegion({
reducer: ee.Reducer.sum(),
scale: 30
}).get('precipitationCal');
return ee.Feature(null, {value: value, date: imergdate2});
});
// Create a graph of the time-series.
var graphTS = ui.Chart.feature.byFeature(timeSeries,'date', ['value']);
print(graphTS.setChartType("LineChart")
.setOptions({title: 'NASA GPM IMERG 30-minute rainfall time-series',
vAxis: {title: 'Rainfall estimates (mm)'},
hAxis: {title: 'Date'}}));
// Create a graph of the accumulation.
var graphAcc = ui.Chart.feature.byFeature(accumulation,'date', ['value']);
print(graphAcc.setChartType("LineChart")
.setOptions({title: 'NASA GPM IMERG 30-minute rainfall accumulation',
vAxis: {title: 'Rainfall estimates (mm)'},
hAxis: {title: 'Date'}}));
// Export the result to Google Drive as a CSV.
Export.table.toDrive({
collection: timeSeries,
description:'LS_20191129',
folder:'GEE',
selectors: 'date, value',
fileFormat: 'CSV'
});
// End of script
So far, I got the time-series Chart and CSV, and I happy for that as my first goal. Next step: (1) I would like to have a Chart and CSV for the accumulation data from start to end of the period. The graphAcc (2nd chart) doesn't seem to give me the results I want. Did I missed something in the script?
(2) If I have a CSV file with information on ID,Lon,Lat,Date How to integrate this data as input? So the script above can directly read the list and do rainfall extraction and export to multiple CSVs or append to the list. Any reference or example?
For reference, attached is the data from Chart 1, and I calculate the accumulation manually, and total rainfall for start to end is 558.557 milimeters.