Interpolation¶
This page lists the methods that provide interpolation of the terrain data.
Alphabetical list:
- class nevis.linear_interpolant(grad=False)[source]¶
Returns a linear interpolation and optionally its gradient over the full GB data set.
When
grad
is set toFalse
(by default), the returned function takes two argumentsx
andy
(both in metres) and returns an interpolated heightz
(in meters).When
grad
is set toTrue
, the returned function takes two argumentsx
andy
(both in metres) and returns a tuple(z, g)
, wherez
is an interpolated height (in meters) andg
is a tuple(dz/dx, dz/dy)
.The height for each grid point
(i, j)
is assumed to be in the center of the square from(i, j)
to(i + 1, j + 1)
.Example:
f = linear_interpolation() print(f(1000, 500)) f_grad = linear_interpolation(grad=True) z, (gx, gy) = f_grad(1000, 500) print(f"Height: {z:.2f} m, gradient: ({gx:.2f} m/m, {gy:.2f} m/m)")
- nevis.spline(verbose=False)[source]¶
Returns a spline interpolation over the full GB data set.
The returned function takes two arguments
x
andy
(both in metres) and returns an interpolated heightz
(in meters).Example:
f = spline() print(f(1000, 500))
Notice: Calling this method will result in the creation and storage of a very large cache file in the nevis data directory.