[gdal-dev] Problem creating geo-tiff from scratch

Marco Zuliani zuliani at mayachitra.com
Mon Jul 5 20:56:09 EDT 2010


Dear all,

 I am trying to utilize GDAL to generate a geo-tiff image from scratch. I
have been following the tutorial presented at
http://www.gdal.org/gdal_tutorial.html and I have been reading the
documentation of the functions involved in the process, but so far I have
not beed successfull in accomplishing my goal.

 In the following I will first paste (partially) my routine in the fervent
hope that somebidy can spot my error and help me out. I will denote with
[...] portions of the code that have been omitted because I believe they are
not relevant to my question. After the listing I will present my questions.

 --- CODE BEGINS ---

[...]

    // There is a driver for each supported format. Attempt to register all
known drivers
    // Ensure that GDALAllRegister() has been called before calling
GetDriverByName().
    GDALAllRegister();

    // select the geotiff format for GDAL
    const char *pszFormat = "GTiff";
    GDALDriver *poDriver = GetGDALDriverManager()->GetDriverByName(
pszFormat );

    // make some checks to avoid headaches in the future
    if ( poDriver == NULL )
    {
// take care of the error condition
 [...]
    }

     // get some info regarding the GDAL driver
    char **papszMetadata = poDriver->GetMetadata();

    if ( !CSLFetchBoolean( papszMetadata, GDAL_DCAP_CREATE, FALSE ) )
    {
 // take care of the error condition in case creation is not possible
    }

[...]
 // at this point the some variables used in a while have the following
values
 // width = 251
 // height = 234
 // bands = 4
     // this hosts the list of driver specific control parameters.
    // See http://www.gdal.org/frmt_gtiff.html
    char **papszOptions = NULL;
    papszOptions = CSLSetNameValue( papszOptions, "TWF", "NO" );
    papszOptions = CSLSetNameValue( papszOptions, "TILED", "NO" );

    int height  = FreeImage_GetHeight( I );
    int width   = FreeImage_GetWidth( I );
    // this is the georeferenced image
    const char *options = GDALGetDriverCreationOptionList(poDriver);
    GDALDataset *Ig = poDriver->Create( "test.tif", width, height, bands,
GDT_Byte, papszOptions );
 --- CODE ENDS ---

Questions:

1] The program outputs to the console the following message: "Warning 6:
Driver GTiff does not support TWF creation option". Why? From the
documentation at http://www.gdal.org/frmt_gtiff.html it seems that such
option is supported...

2] From Visual Studio debugger I can see that the values of poDriver are
messed up and also the values of eAccess, nRasterXSize, nRasterYSize, nBands
seem to be scrabled (I would expect nBands = 4, nRasterXsize = 251, etc.).
Does anybody have an idea of what's going on? (Please find below the output
of the debugger Name/Value/Type)

- Ig 0x00000000039fa450 {hTIFF=0x00000000039fa000
ppoActiveDSRef=0x00000000039fa560 poActiveDS=0x00000000039fa450 ...}
GDALDataset
*
+ [GTiffDataset] {hTIFF=0x00000000039fa000 ppoActiveDSRef=0x00000000039fa560
poActiveDS=0x00000000039fa450 ...} GTiffDataset
+ GDALMajorObject {nFlags=33 sDescription={...} oMDMD={...} }
GDALMajorObject
- poDriver 0x000000fb00000001 {pfnOpen=??? pfnCreate=??? pfnDelete=???
...} GDALDriver
*
+ GDALMajorObject {nFlags=??? sDescription={...} oMDMD={...} }
GDALMajorObject
 pfnOpen CXX0030: Error: expression cannot be evaluated
 pfnCreate CXX0030: Error: expression cannot be evaluated
 pfnDelete CXX0030: Error: expression cannot be evaluated
 pfnCreateCopy CXX0030: Error: expression cannot be evaluated
 pDriverData CXX0030: Error: expression cannot be evaluated
 pfnUnloadDriver CXX0030: Error: expression cannot be evaluated
 pfnIdentify CXX0030: Error: expression cannot be evaluated
 pfnRename CXX0030: Error: expression cannot be evaluated
 pfnCopyFiles CXX0030: Error: expression cannot be evaluated
 eAccess 234 GDALAccess
 nRasterXSize 4 int
 nRasterYSize 60761968 int
 nBands 0 int
+ papoBands 0x0000000100000000 GDALRasterBand * *
 bForceCachedIO 0 int
 nRefCount -1163005939 int
 bShared 0 int
+ oOvManager {poDS=0x0000000000000000 poODS=0xbaadf00dbaadf00d
osOvrFilename={...} ...} GDALDefaultOverviews

Thanks in advance for your help,
Marco

Marco Zuliani, Phd

phone: +1 805 967 9828
web: www.mayachitra.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/gdal-dev/attachments/20100705/5a344881/attachment-0001.html


More information about the gdal-dev mailing list