views:

1028

answers:

4

hi, I am currently working on a data visualization project.My aim is to produce contour lines ,in other words iso-lines, from gridded data.Data can be temperature, weather data or any kind of other environmental parameters but only condition is it must be regularly spaced. I searched in internet , however i could not find a good algorithm, pseudo-code or source code for producing contour lines from grids. Does anybody knows a library, source code or an algorithm for producing contour lines from gridded data? it will be good if your suggestion has a good run time performance, i don't want to wait my users so much :)

Edit: thanks for response but isolines have some constrains like they should not intersects so just generating bezier curves does not accomplish my goal.

A: 

there's some reasonably good contouring available in GNUplot - if you're able to use GPL code that may help.

Alnitak
+1  A: 

See this question: http://stackoverflow.com/questions/533467/how-to-approximate-a-vector-contour-from-an-elevation-raster

It's a near duplicate, but uses quite different terminology. You'll find that cartography and computer graphics solve many of the same problems, but use different terminology for them.

Paul Tomblin
That is a duplicate. "gridded data" <=> "raster data", "data" <=> "elevation", etc.
Jason S
A: 

As the link from Paul Tomblin suggests, Bezier curves (which are a subset of B-splines) are a ripe solution for your problem. If runtime performance is an issue, Bezier curves have the added benefit of being constructable via the very fast de Casteljau algorithm, instead of drawing them according to the parametric equations. On the off chance you're working with DirectX, it has a library function for the de Casteljau, but it should not be challenging to brew one yourself using the 1001 web pages that describe it.

Not Sure
A: 

If your data is placed at regular intervals, this can be done fairly easily (assuming I understand your problem correctly). First you need to determine at what interval you want your contours. Next create the grid you are going to use to store the contour information (i'm assuming just a simple on/off or elevation at this contour level type of data), which should be one interval smaller than the source data.

Now the trick here is to offset the 2 grids by 1/2 an interval (won't actually show up in code like this, but its the concept I'm dealing with here) and compare the 4 coordinates surrounding the current point in the contour data grid you are calculating. If any of the 4 points are in a different interval range, then that 'pixel' in the contour grid should be set to true (or the value of the contour range being crossed).

With this method, there will be a problem when the interval is too fine which will cause several contours to overlap onto each other.

Grant Peters