Upscale Precipitation

I have a data of c(32, 32) array which is 0.2 by 0.2 grid resolution. I want to decrease the resolution 0.4 by 0.4 grid resolution which is to be c(16, 16) array, again 0.8 by 0.8 grid resolution which is become c(8, 8) array.

I develop the following script only for the first c(16, 16) array but it add only the diagonal term a=c(32,32)

# define array

ra <- array(NA, c(16, 16))



for  ( i in seq(1,32,2)) {

       for (j in seq(1,32,2)){


Thank you very much I am looking forward who solve my problem


Using your approach:

a <- array(runif(32 * 32), c(32, 32))
ra <- array(NA, c(16, 16))

n <- 1
for(i in seq(1, 32, 2)){
    k <- 1
    for(j in seq(1, 32, 2)){
        ra[n, k] <- sum(a[i:(i+1), j:(j+1)])
        k <- k + 1
    n <- n + 1

Sure there are more elegant alternatives.

Need Your Help

Add rings to consistent hashing circle to represent data

html5 canvas raphael geometry consistent-hashing

I am implementing consistent hashing and hence drawing a circle with sectors as shown in the Circle Demo. The sectors represents the Nodes.

Want to transform XML having mixed content

xslt xslt-2.0

My XML is like below , I want to convert it to mentioned expected xml format using XSLT 2.0. child1 and child2 are just samples, in actual XML there can be several such node with different names. I...