[gdal-dev] copy raster data in between file formats - Java

Imran Rajjad rajjad at gmail.com
Tue Jun 12 05:04:19 PDT 2012


Hi,

well this kind of operation is well supported under JAI, however it
has the limitations of writing a tiff file under 4GB thats why trying
out GDAL. Anyway checking out
http://trac.osgeo.org/gdal/browser/trunk/gdal/swig/java/apps/GDALTestIO.java

regards,
Imran

On Tue, Jun 12, 2012 at 5:01 PM, Etienne Tourigny
<etourigny.dev at gmail.com> wrote:
> Not sure about the java bindings - but why don't you use the
> CreateCopy() function, which will take care of everything for you?
>
> I'd bet the error is because you didn't include the "band_list" parameter.
>
> Etienne
>
> On Tue, Jun 12, 2012 at 8:31 AM, Imran Rajjad <rajjad at gmail.com> wrote:
>> Dear List,
>>
>> Have been trying to write raster from one file format e.g. BMP into a
>> tiff file which will eventually become a BIGTiff. The current output
>> is a grey image whereas the output should be RGB. The GeoTiFF is not
>> accepting bands for some reasons, To write a multiband geoTiff do we
>> require to add each band separately or is there something missing in
>> the below code snippet?
>>
>>                gdal.AllRegister();
>>                Driver driver = gdal.GetDriverByName("GTiff");
>>                Dataset dst = driver.Create("d:\\test.tif", 256, 256,3,gdalconst.GDT_Byte);
>>                Dataset src = gdal.Open("d:\\test.bmp");
>>
>>
>>                byte[] outputPixels = new byte[src.GetRasterXSize() *
>> src.GetRasterYSize() * src.getRasterCount()*Integer.SIZE];
>>                src.ReadRaster(0, 0, src.getRasterXSize(), src.getRasterYSize(),
>> src.getRasterXSize(), src.getRasterYSize(), gdalconst.GDT_Byte,
>> outputPixels, null, 0);
>>                dst.WriteRaster(0, 0, src.getRasterXSize(), src.getRasterYSize(),
>> src.getRasterXSize(), src.getRasterYSize(), gdalconst.GDT_Byte,
>> outputPixels, null, 0);
>>                dst.FlushCache();
>>                dst.delete();
>>                src.delete();
>>
>>
>> for testing purpose, currently only trying on small 256 x 256 image,
>> the gdalinfo of the source image is as :
>>
>> Files: test.bmp
>> Size is 256, 256
>> Coordinate System is `'
>> Corner Coordinates:
>> Upper Left  (    0.0,    0.0)
>> Lower Left  (    0.0,  256.0)
>> Upper Right (  256.0,    0.0)
>> Lower Right (  256.0,  256.0)
>> Center      (  128.0,  128.0)
>> Band 1 Block=256x1 Type=Byte, ColorInterp=Red
>> Band 2 Block=256x1 Type=Byte, ColorInterp=Green
>> Band 3 Block=256x1 Type=Byte, ColorInterp=Blue
>>
>>
>>
>> regards,
>> --
>> I.R
>> _______________________________________________
>> gdal-dev mailing list
>> gdal-dev at lists.osgeo.org
>> http://lists.osgeo.org/mailman/listinfo/gdal-dev



-- 
I.R


More information about the gdal-dev mailing list