[GRASS-user] Indentify cell with maximum value per category of a cover map
Moritz Lennert
mlennert at club.worldonline.be
Wed May 17 04:07:36 PDT 2017
On 17/05/17 12:07, Johannes Radinger wrote:
> Hi,
>
> I'd like to identify the cell of maximum flow accumulation for each
> subbasin.
>
> For example, I have a cover raster map representing all my subbasins
> (each subbasin has its own cat value). Additionally, I have a flow
> accumulation map. Now, I'd like to get a map with cells that are
> actually those with the largest flow accumulation per subbasin (all
> other cell should be NULL). I guess, using r.stats.zonal/r.statistics I
> can identify the maximum flow accumulation value for each subbasin, but
> this doesn't provide me a map with the corresponding cells!? Is there a
> straight forward way to do that in GRASS with e.g. the mapcalc? Or do I
> need to loop over each subbasin?
Somthing like this might work:
r.stats.zonal cover=bassins base=accumulation output=maxval
r.mapcalc maxpixels = "if(accumulation < maxval+epsilon && accumulation
> maxval - epsilon, 1, null())
The use of an epsilon value is to avoid difficulties of determining
floating point number equalities.
Moritz
More information about the grass-user
mailing list