在两个 x、y、z 点之间线性插值高程

Linearly interpolate elevation between two x,y,z points

我正在尝试获取 x,y,z 点之间的高程值。使用 scipy.interpolate.interp2d,像这样:

x = np.array((140.865, 140.863))
y = np.array((59.8817, 59.8814))
z = np.array((121, 127))
f = scipy.interpolate.interp2d(x,y,z, kind="linear")
z_new = f(140.864,59.58816)

我收到以下错误:

TypeError: m >= (kx+1)(ky+1) must hold

我没有找到关于此类型错误的明确文档。也许我为 interp2d 使用的数据点太少?

根据文档here

The minimum number of data points required along the interpolation axis is (k+1)**2, with k=1 for linear, k=3 for cubic and k=5 for quintic interpolation.

并且由于您使用 linear,(1+1)**2=4,不幸的是您只提供了两个数据点。