<html>
  <head>

    <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
  </head>
  <body bgcolor="#FFFFFF" text="#000099">
    Does anybody know a smart way to calculate for X rasters per raster
    cell the rank order of those rasters? For example, if I have three
    rasters X1, X2 and X3:<br>
    <br>
    X1   X2   X3<br>
    1      3     2<br>
    2      5     8<br>
    5     1      3<br>
    NA  8      2<br>
    <br>
    would give three new raster layers with the values:<br>
    <br>
    Y1   Y2   Y3<br>
    1      3     2<br>
    1      2     3<br>
    3      1     2<br>
    NA   2    1<br>
    <br>
    I am now reading the rasters in R and using a combination of apply()
    and rank() function to create new raster layers:<br>
    <br>
    in <- c("X1",  "X2", "X3")<br>
    lyrs <- readRAST6(in)<br>
    tmp <- apply(lyrs@data, 1, function(x){<br>
        rank(x, na.last="keep", ties.method="average")<br>
    })<br>
    lyrs@data <- t(tmp)<br>
    <br>
    I am sure there are better ways in R, but especially when dealing
    with very large raster layers, I was hoping there is a way to do
    this directly in GRASS GIS. Or otherwise, would it be difficult to
    create a function for this?<br>
    <br>
    Cheers<br>
    <br>
    Paulo<br>
  </body>
</html>