Contour interpolation

Algorithm

Contour interpolation first rasterizes contour lines in the segment map (see also Segments to Raster). This results in values for all pixels that are located on the segments.

Then values have to be calculated for pixels that fall in between the segments. For each undefined pixel, the distance is calculated towards the two nearest contour lines (see also Distance calculation). The distances are calculated forwards and backwards, until no more changes occur. Then a linear interpolation is performed using the two distance values. This returns the value for the undefined pixel.

Example:

The pixel values in this example are calculated as follows:

  1. The value for output pixel no. 1 is determined by the contour lines with value 0m and value 10m. The distance to these contour lines is respectively 1 and 3 and therefore the pixel value will be ((3*10)+(1*0))/4 = 7.5m. This interpolation matches reality.
  2. Pixel no. 2 is situated on a contour line with value 20, and therefore obtains this value. This interpolation also matches reality.
  3. The value for output pixel no. 3 is determined by the contour line with value 10m, and therefore the pixel value will also be 10m. When this area indeed represents a flat area, the interpolation matches reality. However, when the area represents a peak or a valley, this interpolation is wrong. You can then obtain a correct interpretation by adding a small segment representing the highest point of the top or the lowest point of the valley to the segment map.
  4. The value for output pixel no. 4 is determined by the contour lines with value 10m and value 20m. The distance to these contour lines is respectively 2 and 4 and therefore the pixel value will be ((2*20)+(4*10))/6 = 13.33m. This is incorrect, because the output pixel value is most likely to lay within the values 0m and 10m. To avoid these kind of artifects, extend the contour line (segment) with value 10 to the border of the map. The output pixel value will now be determined by the contour lines with value 0m and 10m, and the interpolation will be better.

Reference:

See also: