Search code examples
pythonnumpyinterpolationpoint-clouds

Interpolate and find height above surface


I have a NumPy array of xyz coordinates, all but one representing ground level. I want to interpolate the ground level and find height above surface of one point:

import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D

arr = np.array([[0,0,0,2,2,4,5,5,2],
        [0,3,5,0,5,2,0,5,2],
        [80,70,50,90,40,75,60,46,220]])

x,y,z = arr
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
ax.scatter(x, y, z, zdir='z', c= 'red')
plt.show()

enter image description here

I'm looking for the nomenclature for this, not a solution (I don't know what to search for).


Solution

  • Since your ground level data does not seem to be on a grid you could use LinearNDInterpolator. It uses Delaunay triangulation and is quite robust.

    Another algorithm that I can recommend is Rbf (radial basis function).

    Both are available in scipy and work on n-dimensional data.

    Use one of these two to interpolate the ground level and then calculate the difference to the single value.