[GRASS-user] Calculate average of 3 highest values for a set of raster maps

Paulo van Breugel p.vanbreugel at gmail.com
Fri Mar 15 07:17:13 PDT 2013


My suggestion does just that, per pixel calculations. And as it is just
simple GRASS functions, you should have no problem running it (perhaps a
bit of patients depending on your computer).


On Fri, Mar 15, 2013 at 12:13 PM, Milton Cezar Ribeiro <
miltinho.astronauta at gmail.com> wrote:

> Dear all,
>
> Thanks for all replies. I will check it out thoughout the weekend.
> Just clarifying something, I need to do the estimations focusing on
> each pixels, and not for the full map (I was not that clear before).
>
> Also as my raster maps are very large (~50,000x60,000 pixels) maybe R
> (at least on w7) maybe will not handle the seven rasters.
>
> Best wishes
>
> miltinho
>
> 2013/3/15, Paulo van Breugel <p.vanbreugel at gmail.com>:
> > Sorry, some typo's (but the given code should be ok): set all values <
> > 4/7 quantile to null(), not 0, and you want to calculate the average,
> > not the sum
> >
> > On Fri 15 Mar 2013 10:05:51 AM CET, Paulo van Breugel wrote:
> >> Hi Miltinho
> >>
> >> I assume you want the mean of the three highest values for each raster
> >> cell? If so, you can do this using another step with r.series
> >>
> >> 1) If your 7 maps are a1 .. a7:
> >>
> >> mapcalc "a1 = 1"; r.mapcalc "a2 = 2"; r.mapcalc "a3 = 3"; r.mapcalc
> >> "a4 = 4"; r.mapcalc "a5 = 5"; r.mapcalc "a6 = 6"; r.mapcalc "a7 = 7"
> >>
> >> 2) calculate the 4/7 quantile. Actually, it should be a little bit
> >> smaller to make sure you include your 3rd largest layer. In this
> >> example below, 0.57 as approximation is fine
> >>
> >> r.series --overwrite input=a1,a2,a3,a4,a5,a6,a7 quantile=0.57
> >> output=res1 method=quantile
> >>
> >> 2) Next, for all 7 layers, set all values < 4/7 quantile to 0
> >>
> >> r.mapcalc "b1 = if(a1>res1,a1,null())"
> >> r.mapcalc "b2 = if(a2>res1,a2,null())"
> >> r.mapcalc "b3 = if(a3>res1,a3,null())"
> >> r.mapcalc "b4 = if(a4>res1,a4,null())"
> >> r.mapcalc "b5 = if(a5>res1,a5,null())"
> >> r.mapcalc "b6 = if(a6>res1,a6,null())"
> >> r.mapcalc "b7 = if(a7>res1,a7,null())"
> >>
> >> 3) Now, calculate the sum of the 7 new layers
> >>
> >> r.series input=b1,b2,b3,b4,b5,b6,b7 method=average output=res2
> >> --overwrite
> >>
> >> Your output res2 should have a value 6 for all raster cells.
> >>
> >> Cheers,
> >>
> >> Paulo
> >>
> >>
> >>
> >>
> >>
> >>
> >> On Fri 15 Mar 2013 03:57:35 AM CET, Milton Cezar Ribeiro wrote:
> >>> I have a set of 7 raster maps.
> >>> I am able to calculate several stats with these mapas using r.series.
> >>> Now I need to calculate the mean of the tree highest values of my 7
> >>> maps.
> >>> Any idea of how can I do that?
> >>>
> >>> cheers
> >
>
>
> --
> Miltinho - mcr at rc.unesp.br
> Laboratório de Ecologia Espacial e Conservação - LEEC
> Depto de Ecologia - UNESP - Rio Claro
> Av. 24A, 1515- Bela Vista
> 13506-900 Rio Claro, SP, Brasil
>
> Fone: +55 19 3526-9647 (office)  19 3526-9680 (lab)
> Cel: 19 9853-3220 / 19 9853-5430
>
> Depto Ecologia http://www.rc.unesp.br/ib/ecologia/
>
> PG ECO & BIODIV
> http://www.rc.unesp.br/ib/ecologia/posbiodiversidade/index.php
>
> CV
> http://buscatextual.cnpq.br/buscatextual/visualizacv.do?id=K4792988H6&mostrarNroCitacoesISI=true&mostrarNroCitacoesScopus=true
>
> Google citations http://scholar.google.com/citations?user=OWX_2eAAAAAJ
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/grass-user/attachments/20130315/8f357ff3/attachment.html>


More information about the grass-user mailing list