The two most commonly used models for terrains are the grid and the TIN (triangulated irregular network): A grid terrain is represented as a matrix of elevation values sampled with a uniform grid from the terrain. A TIN terrain is represented as a set of arbitrary elevation samples, whose 2D projections are triangulated. Even though the TIN is clearly more space efficient than the grid because its point density can vary, the grid remains the model most widely used in GIS practice. One reason for this is that the TIN involves complicated data structures for representing the topology, and calculations on TINs are subject to numerical precision issues when encountering small angles or other degenerate cases. In this project we have developed a basic library for handling TINs. We provide support for the standard topological operations, for tracing steepest upslope and downslope paths and for identifying local minima and saddle points.