[Gdal-dev] gdal java bindings
Christopher Condit
condit at sdsc.edu
Thu Jul 27 18:56:57 EDT 2006
Does anyone have experience with the GDAL Java bindings? I'm trying to
use them for raster access and can't seem to get the raw data.
The key problem seems to me that band.GetOffset, GetScale, and
GetNoDataValue are failing. They all return void in the Double[]. Am I
calling them wrong? getXSize/getYsize works fine.
Here's the function:
void dump()
{
Band band = image.GetRasterBand(1);
int x = band.getXSize();
int y = band.getYSize();
ByteBuffer data = ByteBuffer.allocateDirect(x * y);
band.ReadRaster_Direct(0, 0, x, y, x, y,
band.getDataType(), data);
Double[] offset = new Double[1], scale = new Double[1],
nodata = new Double[1];
band.GetOffset(offset);
band.GetScale(scale);
band.GetNoDataValue(nodata);
double min = 1000;
double max = -1000;
while (data.hasRemaining())
{
double val = (data.get() * scale[0]) +
offset[0];
if (val < min)
min = val;
if (val > max)
max = val;
}
System.out.println(min + " " + max);
}
Thanks,
Chris
More information about the Gdal-dev
mailing list