# 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)) n=0 k=0 for ( i in seq(1,32,2)) { for (j in seq(1,32,2)){ ra[n,k]=sum(a[i:(i+1),j:(j+1)]) } n=n+1 k=k+1 }

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

## Answers

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.