TransWikia.com

Daily rainfall chart in a polygon between dates in GEE

Geographic Information Systems Asked by Claudio Hernández on December 6, 2020

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

One Answer

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

Answered by Claudio Hernández on December 6, 2020

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP