[GRASS-user] How to find the second largest value in a series of
rasters.
Glynn Clements
glynn at gclements.plus.com
Fri Dec 9 17:25:17 EST 2011
Marcello Gorini wrote:
> I have to find the maximum value for each cell in a series of rasters and
> generate both a maximum value map and a categorical map with the raster
> number which contains the maximum value.
>
> R.series is, therefore, perfect to accomplish that using
> method=maximum,max_raster.
>
> My problem is that I also need to find the *second largest* value and the
> corresponding raster number which contains the second largest value.
>
> I am doing that by iterating over all classes through a shell script, but it
> obviously takes much more time than using a simple r.series command.
>
> Can anyone share any idea on how to accomplish that using r.series or
> something similar?
There isn't an efficient way to do this using existing tools. If you
need the efficiency, I suggest adding a "second largest" aggregate to
lib/stats (based upon c_max.c and c_maxx.c), and updating r.series to
use it.
--
Glynn Clements <glynn at gclements.plus.com>
More information about the grass-user
mailing list