-1

I would like to make a chart of daily rainfall in a polygon of a shape file collection.

var inidate = ee.Date.fromYMD(2020,5,1)
var enddate = ee.Date.fromYMD(2020,11,10)
// 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/operational')
.map(function(im){return im.clip(cz.filterMetadata("polygon","contains","polygon1"));})
.filterDate(inidate, enddate)
.select('hourlyPrecipRateGC');
print(gsmap.size());
// Time lapse
var lapse = ee.List.sequence(0, difdate.subtract(1))
var inidate = ee.Date('2020-05-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, 1000).get('hourlyPrecipRateGC')
return feat.set(day.format('YYYY-MM-dd'), value)})
// Return the FeatureCollection with the new properties set
return temp_ft}, czcz.filterMetadata("polygon","contains","polygon1")))
// get the dates and the rain intensity per day
var dates = newft.first().toDictionary().keys();
var rain = newft.first().toDictionary().values();
// build a feature collection with property rain and date
var correctFeats = ee.FeatureCollection(dates.map(function(date){
var ind = dates.indexOf(date);
var rainAtDate = rain.get(ind);
var feat = ee.Feature(czcz.filterMetadata("polygon","contains","polygon1"))
return feat;
}));
print(correctFeats);
Making a chart
var chart = ui.Chart.feature.byFeature(correctFeats, 'date', 'rain')
print(chart);
2
  • Could you describe not just what you want to do, but what you have so far? What does the code you have do, and how does it differ from what you want? That will help people answer your question.
    – Kevin Reid
    Nov 20, 2020 at 15:49
  • Thanks for answering Kevin. I have a shp with many polygons. Ywould like to see the daily precipitation chart for each polygon between dates. Nov 20, 2020 at 15:51

1 Answer 1

0

i found this code which helped me

var fc = cz.filterMetadata("Polygon","contains","Polygon1");

Map.centerObject(cz,10);
/*/Genera una colección de imágenes del producto 3B42 para una ventana de tiempo filtradas por el área definida anteriormente/*/
var collection = ee.ImageCollection('JAXA/GPM_L3/GSMaP/v6/operational')
.filterDate('2020-08-01','2020-08-30')

print(collection);
/*/Generar una variable “median” que es la media de la precipitación para la ventana de tiempo de la
colección obtenida anteriormente. Luego, la función “clip” recorta la variable anterior al área definida para su visualización /*/

var media = collection.mean();
var imagen = media.clip(fc);
Map.addLayer(imagen);

/*/Generar un grafico de evolucion temporal para la colleccion generada /*/

var GsmChart = ui.Chart.image.series({
imageCollection: collection.select('hourlyPrecipRate'),
region: fc,
reducer: ee.Reducer.mean(),
scale: 30
})
.setOptions({
title:'',vAxis:{title:'precipitacion (mm/hr)'}
});
/*/ Mostrar el grafico en la consola /*/
print(GsmChart);
2
  • Did it help or did it also solve your problem?
    – MarcM
    Nov 20, 2020 at 16:53
  • It allows me to get the precipitation in a specific polygon, but it still doesnt show the daily sum though Nov 20, 2020 at 17:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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