Interpolation

The general problems and solutions that are involved in three-dimensional interpolation can be illustrated by some two-dimensional examples.  Linear interpolation involves the fitting what can be thought of a as straight line-segments between the control points, while spline interpolation involves the fitting of a smooth curve that passes through the individual control points.

# linear and spline interpolation benign case
xctrl <- c(0.00,0.52,0.88,1.22,1.52,1.73,1.90,2.07,2.52,2.94,3.20,3.75)
yctrl <- c(0.37,0.50,0.72,0.68,0.75,0.80,1.00,0.97,0.50,0.50,0.40,0.40)
xtarg <- c(seq(00.0, 4.2, 0.05))

# linear interpolation
plot(xctrl, yctrl, pch=16, cex=1.5)
yhat <- approx(xctrl, yctrl, xout=xtarg, method="linear", rule=1, f=0)
points (yhat)
lines (yhat)

# constant interpolation
plot(xctrl, yctrl, pch=16, cex=1.5)
yhat <- approx(xctrl, yctrl, xout=xtarg, method="constant", rule=1, f=0)
points (yhat)
lines (yhat)

# spline interpolation
plot(xctrl, yctrl, pch=17, cex=1.5)
yhat <- spline(xctrl, yctrl, n=100)
points (yhat)
lines (yhat)

There are some particular configurations of the control points that produce results that are less than desirable, and the choice of an appropriate interpolation method is often an overlooked task in contouring.  A couple of examples illustrate situations when basic interpolation procedures do not work well.

# linear and spline interpolation -- suboptimal case
xctrl <- c(0.00,0.52,0.88,1.22,1.82,1.93,2.02,2.07,2.52,2.94,3.20,3.75)
yctrl <- c(0.37,0.50,0.72,0.68,0.25,0.80,1.10,0.97,0.50,0.30,0.40,0.40)
xtarg <- c(seq(00.0, 4.0, 0.05))

# linear interpolation
plot(xctrl, yctrl, pch=17, cex=1.5)
yhat <- approx(xctrl, yctrl, xout=xtarg, method="linear", rule=1, f=0)
points (yhat)
lines (yhat)

# spline interpolation -- suboptimal case
plot(xctrl, yctrl, pch=17, cex=1.5)
yhat <- spline(xctrl, yctrl, n=100)
points (yhat)
lines (yhat)

 

[back to topics and examples] [Geog 4/517] [Geog. 4/517 lectures]