Dear all

I am trying to count the number of group of depressions (negative
values) from a climate data set and have least idea on how to go about it.
Let me explain the scenario.
I have a raster brick with 468 layers and and each layer has 7458 cells.


> cntnegclass       : RasterBrick
dimensions  : 66, 113, 7458, 468  (nrow, ncol, ncell, nlayers)
resolution  : 0.108, 0.108  (x, y)
extent      : 77.946, 90.15, 24.946, 32.074  (xmin, xmax, ymin, ymax)
coord. ref. : NA
values      : in memory
min values  : -359.51 -341.21 -315.45 -148.10 -187.39  -52.87  -66.72
-52.17 -286.81 -306.74 ...
max values  :  -7.589   0.000   0.000   0.000   0.000   0.000   0.000
 0.000   0.000   0.000 ...



Now for example lets take the 5000th pixel

> cntneg[5000]

Which will give me 468 values of that pixel over time.


[1]  -90.795107  -89.990016  -94.840754    0.000000  -15.085517    0.000000
  [7]    0.000000    0.000000    0.000000  -12.469657 -114.757702 -115.372023
 [13] -107.194478  -92.916680 -115.105817 -113.205776 -115.003430  -62.175070
 [19]    0.000000    0.000000    0.000000  -72.358073 -105.006508 -115.372023
 [25]  -48.836959 -102.314928 -113.271826 -115.372023  -79.530055    0.000000
 [31]    0.000000    0.000000    0.000000  -15.048987 -115.208204 -115.372023
 [37] -115.003430 -108.757617 -113.122594 -115.372023 -111.699048  -17.618498
 [43]    0.000000    0.000000


Now here I need to do two tasks

1) count number of times the rainfall went below the average - those with
negative values. And zeros are with positive RF values (which i converted
to zero using reclass) for the ease of calculation.
In the above example I want to pick the group of negative numbers and
count. ie,  (-90.795107  -89.990016  -94.840754), (-15.085517), (
-12.469657 -114.757702 -115.372023,  -107.194478  -92.916680 -115.105817
-113.205776 -115.003430  -62.175070), (-72.358073 -105.006508 -115.372023,
-48.836959 -102.314928 -113.271826 -115.372023  -79.530055)  etc. The
resulted layer pixel value should be the count of these groups, which in
this case is 5. Like wise need to do for all the pixels along time
dimension.

2) For each group I want to pick the minimum values and resulted pixel will
have the sum of those minimum values. If a group has one value, keep the
same.

I am stuck to start with this process. I am assuming I need to convert the
brick into dataframe and do this.

Can any one help me in giving a lead on how to go about it?

Really appreciate any help.


Sorry if the explanation is confusing.

Regards

Sajid






-- 
Sajid Pareeth

IWMI, Colombo

	[[alternative HTML version deleted]]

