[R] Spatial Data Interpolation

Peter Maclean pmaclean2011 at yahoo.com
Sat Jul 30 22:35:32 CEST 2011


Dear GIS people
What is the best way of implemeting spatial data interpolation (from large to small grids)-especially for dummies. I searched the internet and could not get concrete answer. Here is an example with simulated data.
 
#Example of spatial data interpolation
require(utils)
#I need to interpolate the temp and rain data (from its surounding points)
#for the same period and accoubting for elevation
#New coordinates and elevation
lat  <-seq(-1, -5, by=-0.1)
lon  <-seq(28, 30, by=0.1)
year  <- seq(2000, 2005, by=1)
period <- c("Mar", "Apr","May")
ndata <- list(year=year,period=period,lat=lat, lon=lon)
ndata <- expand.grid(ndata)
ndata$elev <-sample(1000: 8000,nrow(ndata),replace=T)
ndata <- ndata[order(ndata$year,ndata$period) , ]
fix(ndata)
 
#Original data with elevation-same period
lat   <- seq(-1, -5, by=-0.5)
lon   <- seq(28, 30, by=0.5)
data <- list(year=year,period=period,lat=lat, lon=lon)
data <- expand.grid(data)
data$temp <- sample(15:100, nrow(data),replace=T)
data$rain <- sample(0: 1000,nrow(data),replace=T)
data <- data[order(data$year,data$period) , ]
data <- na.omit(merge(data,ndata, by=c("year", "period", "lat","lon")))
fix(data)
##########
#Spatial-Temporal Interpolation from original data (temp & rain) to new data


Peter Maclean
Department of Economics
UDSM



More information about the R-help mailing list