[GRASS-user] How to find the second largest value in a series of rasters.

Glynn Clements glynn at gclements.plus.com
Sun Dec 11 13:34:01 EST 2011


Sylvain Maillard wrote:

> what about computing the first largest value, making your categorical map,
> and using it as a mask ?
> 
> if you mask all cell containing the first largest value, then the second
> largest value will become the first largest value of the masked raster
> serie ...

Every cell has a largest value (provided that the cell is non-null in
at least one input map).

The problem can be solved by running "r.series method=max_raster",
then filtering each input map, setting a cell to null if the input
map has the largest value for that particular cell, then running
"r.series method=max" on the filtered maps.

But that's very inefficient compared to implementing a
"second-largest" aggregate directly.

-- 
Glynn Clements <glynn at gclements.plus.com>


More information about the grass-user mailing list