Question

I am looking for a function or example to produce a list of lines representing contours at a specific height within a heightmap.

Eg,

Lines[] = GetContours(Heights[512,512], HeightValue) 

Where Heights is a 512x512 array of floating point values, HeightValue is the height at which the contour should be drawn. Heights may contain multiple lines for that specific height (eg a Saddle, or island chain)

Does anyone have or know where to get an algorithm to generate this?

Was it helpful?

Solution

What you're actually trying to do is to draw an iso-line.
see my question about it a while ago.
The link given in one of the answers was very helpful.

OTHER TIPS

The standard algorithm is marching squares.

Algorithm:

a) Find which polygons have vertices above&below the height you're interested in.

b) Intersect the edges of those polygons with the plane to get lines on the plane.

c) Join the lines together in strips.

Take a look at Srtm2Osm, a tool I've made to generate contours from NASA's SRTM data. You can find the algorithm in the C# code.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top