Great!
        I was trying "order(my.r)" instead of "order(my.r[])".
        Thank you Roman!
        Cheers,

Marcio
www.dsr.inpe.br/~mello


On 11/11/2013 11:15, Roman Luštrik wrote:
Something like this?

library(raster)

my.r <- raster(nrow = 10, ncol = 10)
my.r[] <- runif(ncell(my.r))
plot(my.r)

cell.numbers <- order(my.r[])
cell.numbers[1:10]
  [1]  32  33  81  12  28  98 100  34  69   2
xyFromCell(my.r, cell.numbers[1:10])
          x   y
  [1,] -126  27
  [2,]  -90  27
  [3,] -162 -63
  [4,] -126  63
  [5,]   90  45
  [6,]   90 -81
  [7,]  162 -81
  [8,]  -54  27
  [9,]  126 -27
[10,] -126  81

points(xyFromCell(my.r, cell.numbers[1:10]))

Cheers,
Roman




On Mon, Nov 11, 2013 at 2:05 PM, Marcio Pupin Mello <[email protected]> wrote:

Dear list,
         I have a RasterLayer (raster package) and want to select "n"
smallest values from it (values and coordinates). I figured out that the
which.min function in the raster package give me the coordinate of the
smallest value. But how could I get the 10 smallest values?
         I'm using last version of R for Windows and all the packages.
         Thanks in advance,
--
Marcio
www.dsr.inpe.br/~mello

_______________________________________________
R-sig-Geo mailing list
[email protected]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo





--
Marcio
www.dsr.inpe.br/~mello

_______________________________________________
R-sig-Geo mailing list
[email protected]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo

Reply via email to