[GRASS-user] t.rast.aggregate help

Ciao, Maria Elena

Hallo everybody,
I am trying to aggregate some time-stamped raster (placed in
an initial space-time dataset) but I have some problems; each raster represents
a 1h-cumulated rainfall, so I have something like this:

raster1 | start_time 2014-09-04 12:00:00 | end_time 2014-09-04 13:00:00
raster2 | start_time 2014-09-04 13:00:00 | end_time 2014-09-04 14:00:00
etc

I would like to aggregate from a certain datetime backward adopting
different granularities (2 hours, 3 hours, 4 hours, 5hours and 6 hours) but not
in a ?massive? way, I just need the first aggregation for each granularity. I
came up with something like this:

for i in `seq 2 1 6` ;

do t.rast.aggregate -- o input=initial_dataset output=${i}h_aggregate method=sum basename=${i}h_aggregate granularity="$i hours" sampling=contains where="start_time = datetime('2014-09-04
14:00:00','-$i hours') and end_time
<= '2014-09-04 12:00:00'");

Sorry for late response.
Luca has come with this (probable) solution for your problem...

for i in `seq 2 1 6` ;
do
    end_time=12;
    start_time=`expr $end_time - $i`;
    t.rast.aggregate --o input=initial_dataset output=${i}h_aggregate
method=sum basename=${i}h_aggregate granularity="$i hours"
sampling=contains where="start_time >= "2014-09-04
${start_time}:00:00" and end_time <= "2014-09-04 ${end_time}:00:00";
done

We did not test, so please let us know if it works :slight_smile:
Cheers,

Vero

Ciao Maria Elena!

I'm glad it worked! Kudos to Luca Delucchi that figured it out!

I'm cc-ing the list, so if someone else has a similar doubt/problem
he/she can find a "plausible" solution.

Cheers,
Vero

2015-05-20 5:59 GMT-03:00 Maria Elena Martinotti
<mariaelena.martinotti@hotmail.it>:

Ciao Vero,

thanks for your help, by looking at your solution I found out that my
problem was the definition of the time interval in the sql query; infact I
modified my script like this:

sampling=contains where="start_time >= datetime('2014-09-04 14:00:00' ,
'-$i hours') and end_time <= '2014-09-04 14:00:00'")

and it worked but I think that your solution is more elegant and probably
I'll change my script as you suggest :slight_smile:
Thanks a lot

Cheers,
M.Elena