def trapezoidal_area(xyz):
    """Calculate volume under a surface defined by irregularly spaced points
    using delaunay triangulation. "x,y,z" is a <numpoints x 3> shaped ndarray."""
d = scipy.spatial.Delaunay(xyz[:, :2])
tri = xyz[d.vertices]
a = tri[:, (0), :2] - tri[:, (1), :2]
b = tri[:, (0), :2] - tri[:, (2), :2]
proj_area = np.cross(a, b).sum(axis=-1)
zavg = tri[:, :, (2)].sum(axis=1)
vol = zavg * np.abs(proj_area) / 6.0
return vol.sum()
main()
Volume under "plane" defined by data points - python