Spatial Interpolation in python

EmailTwitterLinkedInFacebookWhatsAppShare

Figure: Spatial interpolation creates continuous surfaces from scattered data

1. What is Spatial Interpolation?

Spatial interpolation is the process of estimating unknown values at unsampled locations based on known values at sampled locations. It transforms sparse, scattered measurements into a continuous surface.

Example: You have temperature readings from 10 weather stations. Spatial interpolation lets you estimate the temperature at ANY location in the region, not just where stations exist.

The Key Assumption:

All spatial interpolation methods assume that nearby locations tend to have similar values – this is Tobler’s First Law of Geography.

2. Tobler’s First Law of Geography

Figure: Tobler’s Law – nearby points are more related than distant ones

“Everything is related to everything else, but near things are more related than distant things.” – Waldo Tobler, 1970

This principle forms the mathematical foundation for all spatial interpolation. It means we should weight nearby measurements more heavily than distant ones when making predictions.

3. Nearest Neighbor Interpolation

Figure: Nearest Neighbor creates Voronoi regions

The simplest method: for any location, use the value of the closest measured point.

Formula: z(x) = z(nearest)

Creates a Voronoi diagram where each region has a constant value. Fast but produces blocky, discontinuous results. Best for categorical data.

4. Inverse Distance Weighting (IDW)

Figure: IDW with different power parameters

IDW uses ALL measured points, weighted by inverse distance. Closer points contribute more than distant ones.

Formula: z(x) = Σ(wᵢ × zᵢ) / Σwᵢ, where wᵢ = 1/dᵢᵖ

The power parameter p controls influence decay: p=1 is smooth, p=2 is standard, p>2 is more local. Simple, fast, and produces smooth continuous surfaces.

5. Triangulation Methods

Figure: Delaunay triangulation and interpolation results

These methods first connect points into triangles (Delaunay triangulation), then interpolate within each triangle.

  • Linear: Flat planes within triangles – fast but shows edges
  • Cubic: Smooth curves (Clough-Tocher) – no visible triangle boundaries

Limitation: Only works within the convex hull of your data points.

6. Radial Basis Functions (RBF)

Figure: Different RBF kernels produce different results

RBF uses radially symmetric basis functions centered at each data point:

Formula: z(x) = Σ λᵢ × φ(||x – xᵢ||)

Common kernels: Multiquadric, Gaussian, Thin Plate Spline, Cubic. RBF produces very smooth results and can extrapolate beyond the data range.

7. Kriging: The Gold Standard

Figure: Kriging concepts – variograms, weights, and uncertainty

Kriging is statistically optimal and uniquely provides UNCERTAINTY estimates with predictions.

Key Concept: The Semivariogram

γ(h) = ½ E[(Z(x) – Z(x+h))²] describes how variance changes with distance.

Variogram parameters: Nugget (measurement error), Sill (maximum variance), Range (correlation distance).

Types: Simple Kriging (known mean), Ordinary Kriging (unknown constant mean), Universal Kriging (with trend).

8. Method Comparison

Figure: Side-by-side comparison of all methods with RMSE

Each method has strengths: Nearest Neighbor for speed, IDW for simplicity, RBF for smoothness, Kriging for uncertainty quantification.

9. Real-World Applications

Figure: Applications in weather, terrain, pollution, and mining

  • Meteorology: Temperature and precipitation mapping
  • Terrain: Digital Elevation Models from survey points
  • Environment: Air quality and pollution mapping
  • Mining: Ore grade estimation from borehole samples
  • Agriculture: Soil property mapping for precision farming

10. Choosing the Right Method

Figure: Decision guide for selecting interpolation method

Need uncertainty? → Kriging. Need speed? → IDW or Nearest Neighbor. Need smoothness? → RBF or Cubic. Have regular grid? → Splines.

11. Python Implementation

Essential imports for spatial interpolation:

12. Summary

  • All methods based on Tobler’s Law: nearby = more related
  • Nearest Neighbor: Fast, blocky – good for categories
  • IDW: Simple weighted average – good general purpose
  • Triangulation: Works within convex hull only
  • RBF: Very smooth, can extrapolate
  • Kriging: Optimal, provides uncertainty estimates

Best practice: Start simple, validate results, increase complexity only if needed.


I hope this tutorial will create a good foundation for you. If you want tutorials on another topic or you have any queries, please send an mail at [email protected].

Leave a ReplyCancel reply

Discover more from Spatial Dev Guru

Subscribe now to keep reading and get access to the full archive.

Continue reading

Discover more from Spatial Dev Guru

Subscribe now to keep reading and get access to the full archive.

Continue reading