# [SciPy-User] Calculate surface area and volume from intersection of volume and plane.

Robert Kern robert.kern@gmail....
Tue Aug 30 13:41:33 CDT 2011

```On Tue, Aug 30, 2011 at 08:44, Dharhas Pothina
<Dharhas.Pothina@twdb.state.tx.us> wrote:
> Hi,
>
> We have an old ArcGIS aml script that we are trying to replace. The original
> script takes the input from an ArcGIS TIN model (basically a 2D delaunay
> triangulation of irregular xy data points with z's defining the depth at
> each xy) and calculates the surface area and volume of the lake at different
> elevations (i.e. z cut planes)
>
> From my googling it looks like I have options for the delaunay triangulation
> using scipy, matplotlib, cgal or mayavi. I'm not sure how to do the surface
> area and volume calculations at various z planes once I have the
> triangulation. I would appreciate any pointers.

Your previous email came through fine. There is no need to repeat it.

It's relatively straightforward to find the polygon of intersection
between the Z plane and the TIN. Just loop through the triangles and
check each of the 3 sides to see if one end is above while the other
end is below. Simple geometry determines the point of contact of that
side. Join up the two sides into a line segment and add that to your
list of line segments. The line segments join up into an irregular
polygon, probably with holes. The area of this polygon can be found by
a formula that you can Google for. E.g.:

http://paulbourke.net/geometry/polyarea/

The volume can be calculated similarly. You can break up the volume
into triangular prisms projecting up from each of the triangles in the
TIN below the Z-plane. You can calculate the volume of each of those
prisms easily. Just be sure to properly take into account the
triangles that intersect the Z-plane. You only want to count the part
that's below the Z-plane.

--
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless
enigma that is made terrible by our own mad attempt to interpret it as
though it had an underlying truth."
-- Umberto Eco
```