[R] Interpolate irregularly spaced data without typical convex hull

tbrowning700 at hotmail.com tbrowning700 at hotmail.com
Tue Jul 30 13:17:04 CEST 2013


I have some irregularly spaced data points I want to interpolate (and ideally
extrapolate marginally beyond). I have been using Akima and predict surface
but this interpolates through the whole convex hull region. As this space
includes a large region where there are actually no data points I want to
curb the extent to which it does this.

Hopefully the following will make this somewhat more clear!

#load Akima library
library(akima)
#define data
x<-c(seq(1,10,by=1),c(4,2,2,9,8,6))
y<-c(seq(1,10,by=1),c(1,2,4,6,8,9))
z<-c(seq(1,16,by=1))
df<-as.data.frame(cbind(x,y))
colnames(df)<-c("x","y")
#perform tps interpolation
Tps(df,z)->out
#output surface data
out2<-predict.surface(out,extrap=F)
#plot
image(out2,xlim=c(0,10),ylim=c(0,10))
points(df)

I want to curb the interpolation are to something more like this (although a
bit smoother!)

df_poly<-cbind(c(4,5.5,5,1),c(5,6,9,6))
polygon(df_poly,col="white",border="white")
extrap and cull.mask in predict.surface seemed promising but could just not
get this to work?

Any help appreciated!
Cheers



More information about the R-help mailing list