# Optimum grid/pixel size for interpolating rainfall and temperature

I have a set monthly rainfall and temperature data within an approximately 100 x 100 km study area. The sampling points are unevenly distributed within the study area. Based on a paper by Janis et. al, the number of samples is more than enough.

I plan to create a raster layer by interpolating the data using either Inverse Distance Weighting or Spline techniques. I can't decide on the best grid/pixel size to use. Is there a certain tull of thumb given an x number of samples and a y size of the study area to determine the best grid size to use?

-

## 2 Answers

The PRISM Climate Group's precipitation raster below is at an 800 m scale. They also have 2 km and 4 km climate products. Climate source uses both 400 m and 2 km grids for their precipitation products. A description of the PRISM methods can be found here. A study area, for example, in the Rocky Mountains would benefit from a greater resolution, while a study area in the Great Plains would have more homogeneous precipitation characteristics, which would allow you to increase your resolution. Of course, the distribution of your sampling points will also set a cap on your resolution. I hope this helps.

-
+1, Also Hengl (2006) has an article that might be of interest as well, Finding the right pixel size. I don't see a public version of the article, but Hengl has a nice webpage devoted to discussion of it though. – Andy W Jul 7 '12 at 15:27
I am accepting this answer. The comment of Andy W is equally good as well. – maning Jul 12 '12 at 8:45

I have written an R function that performs a robust regression (least absolute deviation method) against a DEM to up-sample climate variables. It works quite well for smaller areas where the gradient in the [X,Y] domain does not effect the estimates and is quite superior to resampling and interpolation techniques. It is a loose implementation of Nick Zimmermann's Fortran code. I find that a random sample usually provides the best results however, for comparison sake, you may want to try a systematic sample as well. Other than needing enough RAM to hold the subsample and run the model, as long as a output raster file is specified, it is memory safe.

##########################################################################
# PROGRAM: RasterUpSample.R
# USE: UP SAMPLES A RASTER USING ROBUST REGRESSION
# REQUIRES: RGDAL FORMAT COMPATIBLE RASTERS
#           PACKAGES: MASS, sp, raster, rgdal
#
# ARGUMENTS:
#  x                X (HIGHER RESOLUTION) INDEPENDENT VARIABLE RASTER
#  y                Y (LOWER RESOLUTION) DEPENDENT VARIABLE RASTER
#  p                PERCENT SUBSAMPLE (DEFAULT=0.05 or 5%)
#  sample.type      TYPE OF SAMPLE (random OR systematic); DEFAULT IS random
#  file             IF SPECIFIED, A RASTER SURFACE WILL BE WRITTEN TO DISK.
#                     THE FILE EXTENSION WILL DICTATE THE RASTER FORMAT.
#  ...              ADDITIONAL ARGUMENTS PASSED TO predict
#
# EXAMPLES:
#    setwd("C:/ANALYSIS/TEST/RRR")
#    x <- paste(getwd(), paste("elev", "img", sep="."), sep="/")
#    y <- paste(getwd(), paste("precip90", "img", sep="."), sep="/")
#    RasterUpSample(x=x, y=y, p=0.01, sample.type="random", filename="RPREDICT.img")
#      praster <- raster( paste(getwd(), "RPREDICT.img", sep="/"))
#      Y <- raster(paste(getwd(), paste("precip90", "img", sep="."), sep="/"))
#     op <- par(mfrow = c(1, 2))
#        plot(Y)
#        plot(praster)
#     par(op)
#
# CONTACT:
#     Jeffrey S. Evans
#     Senior Landscape Ecologist
#     The Nature Conservancy
#     Central Science/DbyD
#     Affiliate Assistant Professor
#     Environment and Natural Resources
#     University of Wyoming
#     Laramie, WY 82070
#     jeffrey_evans@tnc.org
#     (970) 672-6766
##########################################################################
RasterUpSample <- function(x, y, p=0.05, sample.type="random", filename=FALSE, ...) {
if (!require(MASS)) stop("MASS PACKAGE MISSING")
if (!require(sp)) stop("sp PACKAGE MISSING")
if (!require(raster)) stop("raster PACKAGE MISSING")
if (!require(rgdal)) stop("rgdal PACKAGE MISSING")
X <- stack(x)
Y <- raster(y)
if(sample.type == "random") {
print("SAMPLE TYPE RANDOM")
SubSamps <- sampleRandom(X, ((nrow(X)*ncol(X))*p), sp=TRUE)
}
if(sample.type == "systematic") {
print("SAMPLE TYPE SYSTEMATIC")
SubSamps <- sampleRegular(X, ((nrow(X)*ncol(X))*p), asRaster=TRUE)
SubSamps <- as(SubSamps, 'SpatialPointsDataFrame')
}
Yvalues <- extract(Y, SubSamps)
SubSamps@data <- data.frame(SubSamps@data, Y=Yvalues)
( rrr <- rlm(as.formula(paste(names(SubSamps@data)[2], ".", sep=" ~ ")),
data=SubSamps@data, scale.est="Huber", psi=psi.hampel,
init="lts") )
if (filename != FALSE) {
predict(X, rrr, filename=filename, na.rm=TRUE, progress='window',
overwrite=TRUE, ...)
print(paste("RASTER WRITTEN TO", filename, sep=": "))
}
print(paste("MEAN RESIDUAL ERROR", round(mean(rrr\$residuals), digits=5), sep=":"))
print(paste("AIC", round(AIC(rrr), digits=5), sep=": "))
return(rrr)
}
-