A question about heightfield

classic Classic list List threaded Threaded
4 messages Options
Zj Zj
Reply | Threaded
Open this post in threaded view
|

A question about heightfield

Hi,
I am new to osgEarth.I want to use GDAL to process the image data(the source are tifs) and get the elevation of each pixel,then I can use the elevation data directly in osgEarth .But the value is different from the height in osgEarth(using tms driver),I want to know how the data changes but just found that height field data is loaded from source.
The code is in osg::HeightField* TileSource::createHeightField(const TileKey&        key, ProgressCallback*     progress).

The function I'm using is GDALRasterBand::RasterIO.I don't know why the value is different from the heightfield.

So, my question now is:
1)Why are they different? How does the value change?
2) How can I get the same height value using GDAL as in osgearth?
My english is not so good, I hope you understand my question.
Thanks
gwaldron gwaldron
Reply | Threaded
Open this post in threaded view
|

Re: A question about heightfield

First, the osg::Array you are looking at is a 17x17 vertex mesh; so the values are being interpolated to match the vertex positions.

Second, GDAL::RasterIO returns image data with an upper-left origin. The osgEarth data has a lower-left origin (OpenGL convention) and osgEarth flips it vertically after reading it with GDAL::RasterIO.

Hope this helps.
Glenn Waldron / Pelican Mapping
Zj Zj
Reply | Threaded
Open this post in threaded view
|

Re: A question about heightfield

Hi Glenn,

It seems that I really don't know enough about osgearth. I also want to ask what interpolation method is used? Can I get the source code?

Thanks for your reply.

Zj
gwaldron gwaldron
Reply | Threaded
Open this post in threaded view
|

Re: A question about heightfield

Bilinear interpolation is usually used for elevation data. There's some code in HeightFieldUtils.
Glenn Waldron / Pelican Mapping