Skip to content

The contour surface (TIN)

What this page covers: how CivilSurvey Expert turns a job's points into a surface of triangles, and how it draws the contours on that surface. It covers the breaklines, the Longest triangle side, the contour levels, smoothing and Only inside the boundary. At the end is a worked example you can check with a calculator.

Read this before you rely on the contours, the levels in the readout or the volumes. Every figure in the Contour screen (contours, spot levels, the cut and fill, the pond capacity, sections and profiles) is taken from this one surface.

What is worked out

  • The surface: a TIN (triangulated irregular network), a network of triangles with a surveyed point at every corner. Inside each triangle the ground is taken as the flat plane through its three corners.
  • The contours: for each contour level, the line where the TIN is at that level, traced across the triangles.

The surface and the contours are worked out again whenever the points, the codes picked as breaklines or the Longest triangle side change. In the side panel, 2 Surface and contours shows the result. For the worked example at the end of this page it says "2 triangles. 1 with a side over 50 m is left out at the edges." and "8 contours from 50.250 to 52.000, 2 of them major (every 1.00 m), smoothed."

1. The points that take part

  • A row with no easting, northing or R.L. is left out.
  • A point under 5 cm (in plan) from an earlier point is merged into that earlier one: the earlier point is kept and the later one is not used. 1 Points says how many were merged, with Show them.
  • "Earlier" means earlier in the file, which is the order the points were surveyed in. The same order is used to join breaklines (step 3).
  • The lowest and highest levels of the points that take part set the range of contour levels (step 5).

2. The triangles

The points are joined into triangles by a Delaunay triangulation in plan: no point lies inside the circle through any triangle's three corners. Of all the ways to join the points, this one gives the triangles closest to equilateral, so each level comes from the nearest points.

The level at any place is the level of the plane of the triangle it falls in. If the triangle's corners are (E₁, N₁, z₁), (E₂, N₂, z₂) and (E₃, N₃, z₃), measure from the first corner:

  • x₂ = E₂ − E₁, y₂ = N₂ − N₁, h₂ = z₂ − z₁
  • x₃ = E₃ − E₁, y₃ = N₃ − N₁, h₃ = z₃ − z₁
  • d = x₂·y₃ − x₃·y₂

Then the plane rises

  • b = (h₂·y₃ − h₃·y₂) / d per metre east, and
  • c = (x₂·h₃ − x₃·h₂) / d per metre north,

and the level at (E, N) is z = z₁ + b·(E − E₁) + c·(N − N₁).

The readout on the plan ("Ground 101.236"), the grid nodes of a volume, and the levels of sections and profiles all come from this formula. A place outside the triangles has no level: the readout says "outside the TIN", and nothing is guessed.

Survey coordinates are often large (UTM eastings in the hundreds of thousands). When the points are more than 50,000 m from 0, CSE first takes a round number of kilometres off every easting and northing, so the sums lose no decimals. Everything is given back in real coordinates.

3. Breaklines along codes

On the Surface page of Contour Settings (F8), Join the points coded lists the points' codes. Tick a code, and its points become a breakline: a line the triangles may not cross.

  • One code makes one line. All the points with that code are joined in the order they were surveyed, first to last. Codes are matched ignoring capitals and the spaces round them, so "dr" and "DR " are the same code.
  • A code with fewer than two points makes no breakline.
  • Each piece of the line becomes an edge of the TIN. Where the Delaunay triangles would cut across a piece, the TIN builder adds a point on the line and splits it there, as often as it must. An added point takes its level along the line, in proportion to its distance from the piece's two ends: z = z_start + (distance from start ÷ length) × (z_end − z_start).
  • Two breaklines that cross are both split at the crossing before the TIN is built. The crossing takes the mean of the two lines' levels there.
  • If the TIN cannot be built with the breaklines, it is built from the points alone. The panel then says so: "The breaklines along DR could not be kept: the TIN is of the points alone."

Because the level along a breakline is straight between its points, a drain's bed or a bund's top is kept as surveyed. Without the breakline, a triangle could join the drain's bed to the top of its bank and fill the drain in.

A code is one line. If two drains are surveyed with the same code, the last point of the first is joined to the first point of the second, straight across the ground between them. Give each drain its own code, such as DR1 and DR2.

4. The longest triangle side at the edges

The Delaunay triangulation always reaches the outermost points, so at the edges of a survey it makes long, thin triangles across ground that was never surveyed (across a bay in the boundary, for example). CSE removes them:

  1. A triangle is left out if one of its sides is longer than the Longest triangle side (Surface page; 50 m to start with) and that side is on the outside of the surface.
  2. Leaving it out puts its other sides on the outside. So the check is made again, until no side on the outside is too long.

Only the outside is peeled. A long triangle with triangles all round it stays. The panel says how many were left out: "6 with a side over 50 m are left out at the edges." or "No triangle has a side over 50 m."

The ground under a left-out triangle has no level. No contour is drawn there, the readout says "outside the TIN", and a volume or pond leaves that part of its boundary out and says so. The Outline boundary runs round the triangles that are kept.

5. The contour levels

  • Interval (Contours page: 0.10, 0.20, 0.25, 0.50, 1.00, 2.00 or 5.00 m; 0.25 to start with). The levels are the multiples of the interval from the lowest point's level to the highest's, counted from 0, not from the lowest point. With 0.25 m and points from 99.316 to 104.880, the levels are 99.500, 99.750 … 104.750. A level a hair from the lowest or highest point counts, and each level is kept to 3 decimals.
  • Major contour every (2, 4, 5 or 10; 4 to start with). A level is major when it is a multiple of interval × this number, again counted from 0. With 0.25 m and every 4th, the majors are the whole metres.
  • Also draw these levels: levels typed with commas between them, such as a formation or an FTL. Each is traced the same way and drawn bold in its own colour. A level outside the surface's levels is not drawn, and the box says so.

The panel's summary counts the levels between the lowest and the highest point, so it can count a level that has no line (one above every triangle that is kept, for example).

6. How a contour is traced

Each triangle is taken on its own, for each level:

  1. If all three corners are on one side of the level, the contour does not cross it.
  2. Otherwise it crosses two of the triangle's sides. On a side from corner 1 (level z₁) to corner 2 (z₂), it crosses at the fraction s = (L − z₁) / (z₂ − z₁) of the way along: E = E₁ + s·(E₂ − E₁) and N = N₁ + s·(N₂ − N₁). This is straight-line interpolation, the same as you would do by hand between two spot levels.
  3. Inside the triangle the contour is the straight line between the two crossings.
  4. A corner exactly at the level counts as just above it, so no piece of contour has no length.

The pieces are then joined end to end through the sides they share with the next triangle. A line that reaches the edge of the surface stops there (an open contour). One that comes back to where it began is closed (a ring round a hill or a hollow). Contours of different levels never cross, because in each triangle they are parallel straight lines.

7. Smoothing

Smooth the lines (Contours page; on for new jobs) draws each contour as a curve. The curve passes through every crossing worked out in step 6, and bends between them. It is a centripetal Catmull–Rom curve: a curve through given points that makes no loops or sharp kinks where the points are unevenly spaced. Each straight piece gets one added point for every 0.5 m of its length, at most 7.

  • The true levels stay where they are. Every vertex of the traced contour is a vertex of the curve, so the smoothed line still passes through the level worked out on each triangle side.
  • No crossings. Where a curved piece would cross another contour (the next level's, another line of the same level, or its own line further on), that piece is drawn straight. Where contours crowd very close together, as round a spike in the data, the pieces near them are drawn straight too.
  • Drawing only. Smoothing changes the plan, the print and the DXF. The volumes, the cell sheet, the readout, the zero line and the sheets always use the true contours and the TIN.

8. Only inside the boundary

Only inside the boundary (Contours page) cuts the contours at the job's boundary. A contour that crosses the boundary is cut into pieces, and only the pieces inside are drawn.

The contours are still traced on the whole TIN first, so a contour inside the boundary is the same whether this is ticked or not. With no boundary, every contour is drawn. The setting does not change any volume: a volume or a pond is always worked out inside its own boundary. See Draw or code a boundary for where the boundary comes from.

Worked example

Five points, all coded GL. The Longest triangle side is 50 m and the Interval 0.25 m, with a major contour every 4th, as for a new job.

Point Easting Northing R.L.
1 100.000 100.000 50.200
2 130.000 100.000 51.300
3 110.000 125.000 50.700
4 140.000 130.000 51.100
5 200.000 112.000 52.000

The triangles. The Delaunay triangulation makes three triangles: 1-2-3, 3-2-4 and 4-2-5. Triangle 4-2-5 has two sides on the outside longer than 50 m: 2 to 5 is √(70² + 12²) = 71.02 m, and 4 to 5 is √(60² + 18²) = 62.64 m. It is left out. The panel says "2 triangles. 1 with a side over 50 m is left out at the edges." Point 5 is now on no triangle: between it and points 2 and 4 there is no level.

The levels. The points run from 50.200 to 52.000, so the levels are 50.250, 50.500 … 52.000: 8 levels. 51.000 and 52.000 are multiples of 0.25 × 4 = 1.00, so they are major. The panel says "8 contours from 50.250 to 52.000, 2 of them major (every 1.00 m), smoothed." No line is drawn at 51.500, 51.750 or 52.000, because they are above every corner of the two triangles that are kept.

The 50.500 contour. In triangle 1-2-3, point 1 (50.200) is below 50.500, and points 2 (51.300) and 3 (50.700) are above it. So the contour crosses sides 1-2 and 1-3:

  • On 1-2: s = (50.500 − 50.200) / (51.300 − 50.200) = 0.30 / 1.10 = 0.2727. E = 100 + 0.2727 × 30 = 108.182, N = 100.000.
  • On 1-3: s = 0.30 / 0.50 = 0.60. E = 100 + 0.60 × 10 = 106.000, N = 100 + 0.60 × 25 = 115.000.

All three corners of triangle 3-2-4 are above 50.500, so the 50.500 contour is the one straight line from (108.182, 100.000) to (106.000, 115.000).

The level at a place. Take E 110.000, N 108.000, inside triangle 1-2-3. From point 1: x₂ = 30, y₂ = 0, h₂ = 1.100; x₃ = 10, y₃ = 25, h₃ = 0.500; d = 30 × 25 − 10 × 0 = 750.

  • b = (1.100 × 25 − 0.500 × 0) / 750 = 0.036667 per metre east
  • c = (30 × 0.500 − 10 × 1.100) / 750 = 0.005333 per metre north
  • z = 50.200 + 0.036667 × 10 + 0.005333 × 8 = 50.609

The readout there says "Ground 50.609".

A breakline. Now say points 1 and 4 are the two ends of a drain's bed. Give them the code DR and tick DR under Join the points coded. The drain's line from 1 to 4 cuts across side 2-3, so the TIN builder adds a point on it, at (118.400, 113.800). That is √(18.4² + 13.8²) = 23.000 m along the 50.000 m from point 1 to point 4, so its level is 50.200 + 23 / 50 × (51.100 − 50.200) = 50.614. Before, the same place was in triangle 1-2-3 at 50.200 + 0.036667 × 18.4 + 0.005333 × 13.8 = 50.948: the drain was filled in by a third of a metre.

The panel now says "4 triangles. 1 with a side over 50 m is left out at the edges." The 50.500 contour bends at the drain line, going from (108.182, 100.000) to (113.333, 110.000) and on to (106.000, 115.000). The readout at E 110.000, N 108.000 now says "Ground 50.433".

To try it in the program, put the five points in a CSV file, make a job and import it (Contours from a point survey, step 7). Turn on TIN on the Contour tab to see the triangles, and move the pointer over the plan to read the levels.