[gdal-dev] java Dataset.GetRasterBand(i).ComputeRasterMinMax not working for float data
mccorb
lists at mcbsystems.us
Fri Jan 27 10:15:59 PST 2017
I have a geotiff image with float data (GDT_Float32). When I read a tile I
have to case the nodata value to float to make it compare otherwise it
doesn't...here is a reduced snippet of my code
Double[] d = new Double[1];
rb.GetNoDataValue(d);
double noDataVal = d[0];
...
if(rasterBandDataType == gdalconstConstants.GDT_Float32)
{
float[] array = new float[(rect.height * rect.width)];
int retVal = rb.ReadRaster(rect.x, rect.y, rect.width, rect.height,
rasterBandDataType, array);
* float noDataValCast = (float) noDataVal;*
for(int i = 0; i < array.length; i++)
{
if(noDataValCast == buff[i])
array[i] = Double.NaN;
else
array[i] = (scale * buff[i]) + offset;
}
}
If I don't cast the noDataVal to a float then the value in the returned
array doesn't equal the noData value
returned from the raster band.
It seems as though the ComputeRasterMinMax call has the same issue as I was
having before I did the casting. I definitely want to use this method it
because it is much faster than pulling the tiles and processing them myself.
I can provide the geotiff file. It is ~100m and wouldn't upload
--
View this message in context: http://osgeo-org.1560.x6.nabble.com/java-Dataset-GetRasterBand-i-ComputeRasterMinMax-not-working-for-float-data-tp5305118.html
Sent from the GDAL - Dev mailing list archive at Nabble.com.
More information about the gdal-dev
mailing list