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

Marco Zuliani zuliani at mayachitra.com
Tue Jul 6 13:48:56 EDT 2010


I noticed that I made another mistake: the band number starts from 1
according to the documentation... So that fixes the NULL problem. Now I am
just puzzled by the behavior of the debugger, even though this is not that
crucial at this point.

Thanks,

Marco Zuliani, Phd

phone: +1 805 967 9828
web: www.mayachitra.com


On Tue, Jul 6, 2010 at 9:49 AM, Marco Zuliani <zuliani at mayachitra.com>wrote:

> Dear Chaitanya,
>
>  thanks a lot for your response. As you pointed out the metadata tag was
> misspelled. Correcting it fixed the first problem. However I still have the
> second problem The inspection of Ig with the debugger shows non consistent
> values for the member variables of the GDALDataset class (see a snapshot at
> the bottom of the email). You suggest that there may be a bug with the
> debugger, but I doubt this is the case. In fact if I continue with the
> execution of the code, the instruction:
>
> [...]
> GDALRasterBand *poBand = Ig->GetRasterBand( b );
> [...]
>
> returns a NULL pointer when b is zero, and this seems to be consistent with
> the fact that the debugger says that Ig is composed of 0 bands (nBands  =
> 0). I would appreciate if you or anybody else have some suggestion to
> understand and solve this problem.
>
> Thanks,
> Marco
>
> --- DEBUGGER OUTPUT BEGINS ---
>
> - Ig 0x0000000003d43b90 {hTIFF=0x0000000003d434c0
> ppoActiveDSRef=0x0000000003d43ca0 poActiveDS=0x0000000003d43b90 ...} GDALDataset
> *
> + [GTiffDataset] {hTIFF=0x0000000003d434c0
> ppoActiveDSRef=0x0000000003d43ca0 poActiveDS=0x0000000003d43b90 ...}
> GTiffDataset
>  + GDALMajorObject {nFlags=33 sDescription={...} oMDMD={...} }
> GDALMajorObject
> + poDriver 0x000000fb00000001 {pfnOpen=??? pfnCreate=??? pfnDelete=???
> ...} GDALDriver *
>  eAccess 234 GDALAccess
>  nRasterXSize 4 int
>  nRasterYSize 64236080 int
>  nBands 0 int
> + papoBands 0x0000000100000000 GDALRasterBand * *
>  bForceCachedIO 0 int
>  nRefCount -1163005939 int
>  bShared 0 int
> + oOvManager {poDS=0x0000000000000000 poODS=0xbaadf00dbaadf00d
> osOvrFilename={...} ...} GDALDefaultOverviews
>
> --- DEBUGGER OUTPUT ENDS ---
>
>
> On Mon, Jul 5, 2010 at 9:13 PM, Chaitanya kumar CH <chaitanya.ch at gmail.com
> > wrote:
>
>> Marco,
>>
>> 1. You misspelled the option for world file creation as 'TWF' which should
>> actually be 'TFW'.
>> 2. The driver did report the error message correctly after processing the
>> creation options. There may be a bug with the debugger.
>>
>>
>> On Tue, Jul 6, 2010 at 6:26 AM, Marco Zuliani <zuliani at mayachitra.com>wrote:
>>
>>> 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
>>>
>>> _______________________________________________
>>> gdal-dev mailing list
>>> gdal-dev at lists.osgeo.org
>>> http://lists.osgeo.org/mailman/listinfo/gdal-dev
>>>
>>
>>
>>
>> --
>> Best regards,
>> Chaitanya kumar CH.
>> /tʃaɪθənjə/ /kʊmɑr/
>> +91-9494447584
>> 17.2416N 80.1426E
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/gdal-dev/attachments/20100706/c01c1d3a/attachment-0001.html


More information about the gdal-dev mailing list