[Gdal-dev] Parse DEM file problem

Clay, Bruce bclay at ball.com
Wed May 5 14:44:51 EDT 2004


I am working on a basic terrain elevation server.  During startup I read
the header of all of the DEM files in the specified directory but do not
read the actual data.  The GDALDataset pointer returned by GDALOpen is
saved in an STL vector along with the header information.

I am using the GTOPO30 data set.

When I use the data set pointer later to read file from E20N40.DEM
GDALComputeRasterMinMax returns min = -405 max = 4099 which should be
min = -407 max = 4525.

When I use the data set pointer later to read file from E20N90.DEM I get
min = -32768 and max = 32521 which should be min = -137 max = 5483.

Walking through the data seems to give the same min and max values (at
least for what I have done so far).

I see plenty of -9999 which the documentation says is the "no data"
marker so it doesn't seem like it is a byte swap issue.

The questions are:
  Does GDAL maintain any state information that I might be overwriting
by reading other headers before reading the data?

  Does anyone have any experience with this data set to know if what to
expect from GDAL when it reads the data?

The code I am using comes right out of the test programs / examples and
is as follows:

	pBand = pDataSet->GetRasterBand( 1 );

	if ((pBand != NULL) && (pHeaderInfo != NULL))
		{
		pBand->GetBlockSize( &nBlockXSize, &nBlockYSize );
		if (mVerbose == TRUE)
			{
			sprintf(msgBuf, "Block=%dx%d Type=%s,
ColorInterp=%s\n",
					nBlockXSize, nBlockYSize,
	
GDALGetDataTypeName(pBand->GetRasterDataType()),
					GDALGetColorInterpretationName(
	
pBand->GetColorInterpretation()) );
			}

		adfMinMax[0] = pBand->GetMinimum( &bGotMin );
		adfMinMax[1] = pBand->GetMaximum( &bGotMax );

		if( ! (bGotMin && bGotMax) )
			{
			GDALComputeRasterMinMax((GDALRasterBandH)pBand,
TRUE, adfMinMax);
			}

Where pDataSet is the stored pointer returned by GDALOpen.


As always any thoughts or suggestions would be greatly appreciated.

Bruce Clay
bclay at ball.com 



More information about the Gdal-dev mailing list