GDALComputeRasterMinMax DEATH!!!

nakiya123 at y... nakiya123 at y...
Thu Nov 29 21:09:34 EST 2001


Ok,
The code is below. The problem is an infinite loop error as
GDALComputeRasterMinMax is called on certain USGS SDTD DEMs. I have a
collection of thousands of dems in this format and have written a
program to extract info out of them. On VERY few of all of these do I
get this error:

ERROR 3: Data record is short on DDF file.

I can understand that that my be some sort of file formatting error,
which is fine. I'd just like to be able to handle it some how scince
the method call does NOT return.

The catcher is gdalinfo opens these "screwed up" dems and displays
it's min/max as outrageous figures like 37000+. I noticed gdalinfo is
in C not C++ so I attempted to write this lower block of code in C. 
Same thing happened. FYI, this block of code worked well on the other
few thousand dems.

int gotMin, gotMax;
double minmax[2];

GDALRasterBand *poBand;

GDALAllRegister();

poDataset = (GDALDataset *) GDALOpen(filename.c_str(), GA_ReadOnly);
if(!poDataset)
{
cerr << "Could not open file: " << filename << endl;
return false;
}

poBand = poDataset->GetRasterBand(1);
if(!poBand)
{
cerr << "Could not get raster band 1\n";
return false;
}

width = poBand->GetXSize();
height = poBand->GetYSize();

minmax[0] = poBand->GetMinimum(&gotMin);
minmax[1] = poBand->GetMaximum(&gotMax);
if(!(gotMin && gotMax))
GDALComputeRasterMinMax((GDALRasterBandH)poBand, TRUE, minmax);

min = minmax[0];
max = minmax[1];

Thanks in advance,







More information about the Gdal-dev mailing list