[Gdal-dev] gdal java bindings

Collins, Benjamin collinsb at mitre.org
Fri Jul 28 10:42:57 EDT 2006


>-----Original Message-----
>From: gdal-dev-bounces at lists.maptools.org 
>[mailto:gdal-dev-bounces at lists.maptools.org] On Behalf Of 
>Christopher Condit
>Sent: Thursday, July 27, 2006 6:57 PM
>To: gdal-dev
>Subject: [Gdal-dev] gdal java bindings
>
>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.
>

A few notes...

Unless you are sure that your data is in byte format, the buffer
allocation of "x * y" is a bad idea as it may under-allocate if your
data has more than one byte per pixel.  Use something like: 
(x * y) * (gdal.GetDataTypeSize(band.getDataType()) / 8);

I looked into the GDAL Docs, and it seems that it is not guaranteed
that scale and offset are going to be set.  In that case, they could be
null or undefined.  Also, you could make sure that you are getting the
number of pixels you expect, and are executing that loop once for each
pixel.  Other than that, I have always had success getting data from
RasterIO.

Sorry I could not help more...feel free to send me the test file that
you were using.
--
Ben





More information about the Gdal-dev mailing list