Interpolation
When a series comes from data (scattered points or grids) rather than from a
formula, func3d makes it samplable through an interpolation
method, chosen in the dataset (method) and adjustable via its parameters.
Here are the available methods, their limits, and a comparison with those offered by
GRASS GIS.
Available methods
| Method | Idea | Parameters | When to use it |
|---|---|---|---|
| nearest | the value of the closest data point (exact query, not approximate) | — | categorical or cell data; to see the "mosaic" (Voronoi) structure of the sampling |
| idw | weighted average with 1/dp weights over the k closest neighbours | power p, number of neighbours k | robust general-purpose method; high p = surface more "insular" around the points |
| bilinear | bilinear interpolation within the cell of a regular grid | — | data already on a grid (rasters, model output); exact at the nodes, continuous everywhere |
| rbf | thin‑plate spline radial basis functions, with diagonal regularisation and a first-degree polynomial term (a thin plate constrained by the points) | regularisation (smoothing) | smooth surfaces from scattered points; the polynomial term guarantees exact reproduction of linear trends, the regularisation avoids oscillations with noisy data |
Common properties: the spatial queries (nearest and the IDW k‑NN) are exact, not heuristic; interpolation happens in data coordinates and the result stays in raw z (the visual scales never touch the values).
Comparing methods: in the series card, the On method change selector decides whether the new interpolant updates the current series (default) or is added as a new series, leaving the original untouched. In the latter case every method change produces one more layer (named after the method used), ready for visual comparison, the multi‑series 2D section or the Difference (A − B) of the Analysis panel.
Comparison with GRASS GIS
For orientation: the most used interpolation modules in GRASS and their equivalent (or absence) in func3d.
| GRASS module | Method | In func3d |
|---|---|---|
v.surf.idw, r.surf.idw |
inverse distance weighting | yes (idw, with adjustable neighbours and power) |
r.resamp.interp |
nearest / bilinear / bicubic / Lanczos on grids | yes, all of them (nearest, bilinear, bicubic, Lanczos) |
v.surf.rst, r.fillnulls |
regularized spline with tension (RST, Mitášová–Mitáš) | yes (rst, with tension and smoothing; the tension-free relative remains the rbf thin‑plate spline) |
v.surf.bspline |
bilinear/bicubic B‑splines with Tykhonov regularisation | yes (bspline: bicubic LSQ + Tykhonov on second differences) |
v.krige |
ordinary kriging (via R) | yes (krige: local ordinary kriging, exponential variogram auto‑fitted with overridable nugget/sill/range) |
addon r.surf.nnbathy |
natural neighbour (Sibson) | yes (natural, exact Sibson via Delaunay) |
The methods born from this comparison
The three candidates singled out below were then implemented, and are now selectable in the series card (the computation runs in the browser):
- RST (spline with tension) — the "signature" GRASS method
(
v.surf.rst): Mitášová–Mitáš kernel E1(ρ)+ln ρ+γ with a constant trend. The tension (default 40, normalised on the data diagonal) moves continuously from a stiff plate to a membrane; the smoothing relaxes the exact pass through the points. - Bicubic (regular grid) — the parallel of
r.resamp.interp method=bicubic: separable C¹ Hermite with step-weighted central difference derivatives (variable spacing supported); exact on quadratics, with 2nd-order one-sided derivatives at the borders. - Natural neighbour (Sibson) — for non-uniform scattered points: Delaunay triangulation and weights equal to the areas "stolen" from the neighbours' Voronoi cells (virtual insertion of the query point). Exact at the points, smooth, parameter-free; no extrapolation outside the convex hull (hole).
The second round also brought Lanczos (uniform grid, 6×6 windowed sinc, exact at the nodes), B‑spline with smoothing (least-squares fit on a bicubic control net + Tykhonov regularisation on the second differences: constants and planes are not penalised, λ governs the smoothing of noisy data) and local ordinary kriging (exponential variogram fitted automatically on the empirical variogram; nugget, sill and range can be set manually — for serious geostatistics, with estimation variance and validation, upstream R/GRASS remains preferable). The table above is now all "yes".
Choosing the base points (RBF and RST)
RBF and RST solve a dense M×M system, where M is the number of base points: with N measured points you cannot take M = N, and the Max base points parameter sets the ceiling. Historically the selection was “one every k” in array order — a choice that depends on how the data was collected, by transects or by successive campaigns, and that on clustered data leaves areas with no base at all: there the interpolation has nothing to lean on and invents.
The method is now chosen in the card:
| Method | What it does | When it helps |
|---|---|---|
| one every k (data order) | takes one point every k in the order they appear in the file | the historical behaviour, and still the default: silently changing the results of someone who has already tuned a chart would be worse than letting them choose |
| maximum coverage (FPS) | farthest point sampling: at each step it adds the point farthest from those already chosen, minimising the covering radius | clustered or transect data, where what matters is that no area is left without a base; it is deterministic |
| random coverage (k‑means++) | a draw weighted by D² (the distance to the nearest chosen point): it covers well without always chasing the maximum, so it is less sensitive to isolated points | when a single very distant outlier would attract FPS; the seed makes the choice reproducible |
The two geometric methods live in js/local/func3d/campionamento.js, a
library of its own with a headless test suite: the yardstick is the covering
radius (the largest distance between any point and the nearest base), which is
exactly what matters for a radial basis. On a 20×20 grid with 25 bases FPS gets
close to the theoretical radius of the regular grid, while “one every k”
stays well above it; on clustered data the gap is stark.
Interpolating a second quantity
When the colour comes from a column other than the height (see extra dimensions in Functions and data series), that column must be interpolated like the height: same method, same parameters, same grid. How this is done is worth stating, because it is a maintenance choice: there is no second interpolation machinery for thematic fields, but a synthetic dataset identical to the original with the chosen column in place of z, which goes through the same eleven methods. That way there are no two paths to keep in step, and a method added tomorrow applies to thematic mapping straight away. The synthetic dataset is hidden: it does not appear among the selectable functions.
Excluded, and why
- 2D LOESS / local polynomials — for very noisy data it produces readable trends; largely overlapping with the regularised RBF and the smoothing B‑spline already available. Low priority.
Note: for proper geostatistical analysis (kriging with variography, cross validation, georeferenced data) the dedicated GIS tools remain preferable; func3d aims at interactive visual exploration.
Keywords: interpolation, nearest, IDW, bilinear, RBF, thin plate spline, GRASS GIS, kriging