# Re: converting contour lines to grids

```Hi Gaoming,

> I need help for converting contour lines to grids.
> . . .
> I tried methods of moving average (with help from Bill and Tom), weighted
> average, and nearest neighbor for interpolation. I am not satisfied with
> the results, because the surfaces between contour lines are actual
> planes. The surfaces do not like a real terrain visually because
> interpolation by moving average, weighted average and nearest neighbor do
> not consider factors such as curvature, convex, and concave.
>
> Recently I am reading the book "OpenGL SuperBible, Second Edition" by
> Richard S. Wright, Jr, and Michael Sweet. There is an example of Bezier
> curve in Chapter 13. Can we do the same thing in Java3d and VisAD?

This is an over-determined problem, in the sense that
there are lots more ways to draw contours than there
are ways to assign numbers to grids. There are no fancy
methods in VisAD to attack this beyond the simple ways
you've already tried. But, for what its worth, here is
a suggestion.

The values at NxM grid points define a point in an
NxM-dimensional space. Given a grid (i.e., a point
in this space), you can interpolate values from this
grid to the points on your contour line, subtract
these from the contour values you want, and take the
sum of squares of these differences over all your
contour points. Your problem is to find the point in
NxM-dimensional space where this sum of squares is
minimum. If you look in the book "Numerical Recipes"
(I'm at a conference and don't have a copy in front
of me) you should be able to find algorithms for
solving this sort of non-linear optimization
problem.

Good luck,
Bill

```
• 2002 messages navigation, sorted by:
• Search the `visad` archives: