[Gdal-dev] GeoTiff projection/transformation problem

Petteri Packalen packalen at cs.joensuu.fi
Sun Feb 16 11:18:10 EST 2003


Hi Everyone,

Below is a piece of code where: (1) a new driver is created, (2) a new
dataset is created based on driver just created, (3) projection and
transformation data are copied to output dataset, and (4) finally input
and output datasets are closed. This works without any problems when
working with IMAGINE files, but when new GTiff dataset is created neither
projection nor affine transformation info is written to the output file
(projection and transformation info are saved properly to output dataset).
The input GeoTiff file is not created by GDAL, but works properly when
processed with libgeotiff. GDAL version is 1.1.8.

I wonder if there is some fundamental problem in my code? Any hints how to
progress?

Example code (not whole program):

// double adfGeoTransform[6];
// GDALDataset  *pInputDS, *pOutputDS;
// char **ppCreateOptions = NULL;
// GDALDriver *pOutDR = NULL;
// GDALDataType inDT;
// const char *pOutProj = NULL;

// Create new driver by short name
pOutDR = DM.GetDriverByName( "GTiff" );

// Create new dataset
pOutputDS = pOutDR->Create( "out.tif", inX, inY, 1, inDT, ppCreateOptions );

// Copy projection info to output dataset
pOutProj = pInputDS->GetProjectionRef();
if ( pOutProj != NULL && strlen( pOutProj ) > 0 )
                pOutputDS->SetProjection( pOutProj );

// Copy affine transformation info to output dataset
if ( pInputDS->GetGeoTransform(adfGeoTransform) == CE_None )
                 pOutputDS->SetGeoTransform( adfGeoTransform );

// Delete datasets
pInputDS->~GDALDataset();
pOutputDS->~GDALDataset();

Best wishes,
Petteri





More information about the Gdal-dev mailing list