[GRASS-user] summing rasters with a condition given by other rasters

Veronica Andreo veroandreo at gmail.com
Mon May 18 14:46:19 PDT 2015


Hi Martin

According to the data you have, you may wanna register your ndvi maps
as relative time, and then:

# with this you select maps between dates pointed out in your sos and
eos maps and put null everywhere else
t.rast.mapcalc -n input=ndvi output=ndvi_sos_eos base=ndvi_sos_eos
expr="if(start_time() >= sos && start_time() <= eos, ndvi, null())"

# and here you estimate the average and sum for the stored ndvi data
for m in 'average sum' ; do
t.rast.series input=ndvi_sos_eos output=ndvi_sos_eos_${m} method=${m}
done

it should work, but i did not test... let me know if it was of any help :)
cheers,
Vero


2015-05-18 4:43 GMT-03:00 Nikos Alexandris <nik at nikosalexandris.net>:
> * Martin_Brandt <martin.brandt at mailbox.org> [2015-05-17 12:44:33 -0700]:
>
>> I have the following issue to solve:
>> There is a MODIS NDVI time series with 23 images for one year, named ndvi_01
>> to ndvi_23. Then i have a
>> raster with integer values from 1-23 representing the start of the growing
>> season (SOS), and the end (EOS), the values differ for each pixel. What i am
>> trying to do is to create a raster which averages (or sums) all NDVI values
>> from ndvi_01 to ndvi_23 which are between SOS and EOS, for an example pixel
>> where SOS is 13 and EOS is 21 that would be an average of the 9 pixels in
>> ndvi_13 to ndvi_21.
>>
>> Is this possible with GRASS 7 under Ubuntu?
>>
>> kind regards,
>> Martin
>
>
> Dear Martin,
>
> this sounds like a perfect use-case for the spatio-temporal framework.
> Take care to timestamp your maps correctly (each NDVI image should carry
> the time of acquisition of its originating MODIS scene I guess).
>
> Then, create a spatio-temporal raster data set (strds) with `t.create` and register
> your maps in it with `t.register`.
>
> Though I don't understand the pattern in the SOS image, you have the
> `t.rast.mapcalc` tool to do all sorts of magic for the strds (as you would regularly do for
> single raster images).
>
> Check in the GRASS wiki an example on using the temporal framework
> <http://grasswiki.osgeo.org/wiki/Temporal_data_processing>.
> There is also the tutotial at
> <http://ncsu-osgeorel.github.io/grass-temporal-workshop/>.  Both are
> excellent.
>
> Best of success, Nikos
> _______________________________________________
> grass-user mailing list
> grass-user at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/grass-user


More information about the grass-user mailing list