[Geotiff] C API for unofficial private tags GDAL_NODATA and GDAL_METADATA

Pierre Soille pierre.soille at jrc.ec.europa.eu
Mon Sep 30 06:27:15 EST 2013


Hello Even,

the code you suggested is working perfectly and is precisely fullfilling
my needs.

Many thanks for your help and best regards,

Pierre




On 09/28/2013 04:32 PM, Even Rouault wrote:
> Le samedi 28 septembre 2013 16:22:13, Pierre Soille a écrit :
>> Hello,
>>
>> when writing GeoTIFF files from a C programme using libgeotiff API, I
>> would like to include the unofficial private tags GDAL_NODATA and
>> GDAL_METADATA.  However, so far I did not succeed doing this for it
>> seems that they are not defined in the current header files associated
>> with libgeotiff-1.4.0.   Any hint would be very much appreciated.
>>
>> Best regards,
> Pierre,
>
> I'd suggest you to use the GDAL library that has abstraction for those 
> details.
>
> Otherwise, if you want to do it at hand, you can try the following code 
> (copied & pasted from the GeoTIFF driver in GDAL)
>
>
> #define TIFFTAG_GDAL_METADATA  42112
> #define TIFFTAG_GDAL_NODATA    42113
> #define TIFFTAG_RPCCOEFFICIENT 50844
>
>
> /************************************************************************/
> /*                          GTiffTagExtender()                          */
> /*                                                                      */
> /*      Install tags specially known to GDAL.                           */
> /************************************************************************/
>
> static TIFFExtendProc _ParentExtender = NULL;
>
> static void GTiffTagExtender(TIFF *tif)
>
> {
>     static const TIFFFieldInfo xtiffFieldInfo[] = {
>         { TIFFTAG_GDAL_METADATA,    -1,-1, TIFF_ASCII,	FIELD_CUSTOM,
>           TRUE,	FALSE,	(char*) "GDALMetadata" },
>         { TIFFTAG_GDAL_NODATA,	    -1,-1, TIFF_ASCII,	FIELD_CUSTOM,
>           TRUE,	FALSE,	(char*) "GDALNoDataValue" },
>         { TIFFTAG_RPCCOEFFICIENT,   -1,-1, TIFF_DOUBLE,	FIELD_CUSTOM,
>           TRUE,	TRUE,	(char*) "RPCCoefficient" }
>     };
>
>     if (_ParentExtender) 
>         (*_ParentExtender)(tif);
>
>     TIFFMergeFieldInfo( tif, xtiffFieldInfo,
> 		        sizeof(xtiffFieldInfo) / sizeof(xtiffFieldInfo[0]) );
> }
>
> /* call it only once in the lifetime of the program before opening/creating a 
> TIFF */
> void InstallGDALTiffTags()
> {
>     _ParentExtender = TIFFSetTagExtender(GTiffTagExtender);
> }
>
> Best regards,
>
> Even
>




More information about the Geotiff mailing list