Closed WindingWinter closed 5 years ago
From the C++ docs
/**
* \brief Fetch the maximum value for this band.
*
* For file formats that don't know this intrinsically, the maximum supported
* value for the data type will generally be returned.
*
* This method is the same as the C function GDALGetRasterMaximum().
*
* @param pbSuccess pointer to a boolean to use to indicate if the
* returned value is a tight maximum or not. May be NULL (default).
*
* @return the maximum raster value (excluding no data pixels)
*/
double GDALRasterBand::GetMaximum( int *pbSuccess )
In Python, when *pbSuccess = FALSE, nothing is returned, which is an acceptable behaviour I think
>>> from osgeo import gdal
>>> ds = gdal.Open('byte.tif')
>>> print ds.GetRasterBand(1).GetMaximum()
None
So similar behaviour in C# seems OK to me
intMaxVal and maxVal are wrong ( ie: no value)
What do you mean by wrong or no value?
What does the intMaxVal
say? Notice, this is boolean flag:
Try this one example.
band.ComputeRasterMinMax(minMax, 0);
Returns proper value for minMax
, but
band.GetMaximum(out val, out hasval);
hasval
returns 0 andval
a very big number
Obviously ComputeRasterMinMax
and GetMaximum
not returning the consistent value as per indicated in the doc.
Obviously
ComputeRasterMinMax
andGetMaximum
not returning the consistent value as per indicated in the doc.
What you get is expected. The TIFF file has no metadata indicating the maximum value, hence GetMaximum(), which doesn''t do any computation, returns the maximum possible value for a Float64 and hasval = 0 to indicate that this value cannot be trusted. ComputeRasterMinMax() on the contrary inspects the raster content.
I have the following code:
It seems that
minMax
value is correct ( because correct values are returned), butintMaxVal
andmaxVal
are wrong ( ie: no value).Why is it so?
I'm using GDAL.Net binding, version 2.3. I suspect that the problem is there also in other Python or C++ bindings.