Triangulate the points, fit value ~ x + y by least squares to the three
corners of each triangle, and evaluate that fit at the cells inside it.
Arguments
- x
coordinates, or coordinates carrying their value as z; see
xyz_input()- value
one value per coordinate, or
NULLto use the z ofx- grid
a
grid_spec()to interpolate onto, orNULLfor a default one- duplicates
function used to combine values at repeated coordinates, or
NULLto leave them alone- ...
ignored
Details
This is the long way round to grid_barycentric(), and the two agree to
floating point. Three points determine a plane, least squares through three
points is that plane, and barycentric interpolation evaluates that same
plane – so the expensive per-triangle lm() and the one vectorised
tsearch() call compute the same surface. Worth seeing once.
It replaces the Delaunay half of facets(), which did this through
spatstat and returned a point pattern rather than a grid.
The Voronoi half of facets() is not here, because it was not doing what it
looked like it was doing. A Voronoi tile contains exactly one point by
construction, so lm(value ~ x + y) on it fits an intercept and nothing
else, and predicts that one point's value across the whole tile. That is
nearest neighbour, computed the slowest way available. grid_voronoi() is
the same answer under its right name.
See also
grid_barycentric() for the fast form of this, grid_voronoi()
for what the Voronoi case really was.
