[gdal-dev] using GDALCreateCopy and changing only the datatype

Yann Chemin yann.chemin at gmail.com
Mon Nov 24 19:36:09 EST 2008

Yes I can see a bit through it,
and I believe the most involved is getting Projection info through...

For a single output band with ncols(nXSize1) and nrows (nYSize1) in
Float32, I can generate an output.
hDataset[n_imgs] =
But it is not georeferenced.

need a bit of reading indeed.

2008/11/25 Frank Warmerdam <warmerdam at pobox.com>:
> Yann Chemin wrote:
>> Hello,
>> I would like to use GDALCreateCopy and change the datatype from int32
>> to float32.
>>        GDALDatasetH hDatasetOut0;
>>        hDatasetOut0 = GDALCreateCopy( hDriver1, ndviF,
>>                                hDataset1,FALSE,NULL,NULL,NULL);
>>        GDALRasterBandH hBandOut0;
>>        hBandOut0 = GDALGetRasterBand(hDatasetOut0,1);
> Yann,
> Generally speaking to do this with CreateCopy() you would need to create
> an intermediate virtual dataset with the altered pixel data type.  This is
> how the -ot flag of gdal_translate works.   You can review the
> gdal_translate.cpp code as an example, though it is somewhat involved.
> Best regards,
> --
> ---------------------------------------+--------------------------------------
> I set the clouds in motion - turn up   | Frank Warmerdam,
> warmerdam at pobox.com
> light and sound - activate the windows | http://pobox.com/~warmerdam
> and watch the world go round - Rush    | Geospatial Programmer for Rent

Yann Chemin
International Rice Research Institute
Office: http://www.irri.org/gis
Perso: http://www.freewebs.com/ychemin
YiKingDo: http://yikingdo.unblog.fr/

More information about the gdal-dev mailing list