[gdal-dev] TIFF with different KEYS_DS
Jorge Martin
jormarfe at gmail.com
Wed May 25 03:49:06 EDT 2011
Hello Frank,
I am trying to test my implementation using GDAL (GDALExtractRPCInfo), but I
do not get any RPC info from my TIFF file. I have pasted below the code I
have used to set/read and test the RPCCoefficientTag managment.
I am involved in a ESA project and my clients used to open the results with
a propietary software, tipically ENVI. I have the specification to fill
RPCCoefficientTag with the same structure defined by GDAL but I do not know
if ENVI is able to open this metadata.
//--------------------------------------------------------------------------------------------------------------------
#define TIFFTAG_RPCCOEFFICIENT 50844
static TIFFExtendProc _ParentExtender = NULL;
static void GTiffTagExtender(TIFF *tif)
{
static const TIFFFieldInfo xtiffFieldInfo[] = {
{ TIFFTAG_RPCCOEFFICIENT, -1,-1, TIFF_DOUBLE, FIELD_CUSTOM,
TRUE, TRUE, (char*) "RPCCoefficient" }
};
if (_ParentExtender)
(*_ParentExtender)(tif);
TIFFMergeFieldInfo( tif, xtiffFieldInfo,
sizeof(xtiffFieldInfo) / sizeof(xtiffFieldInfo[0]) );
}
void SetTAG(){
TIFF * tiff =
TIFFOpen("/home/jjmf/sample_images/OutputTIFF/input_tiff_2.tif", "r+");
if (!tiff)
{
cout << "Unable to open " << endl;
exit(0);
}
double adfRPCTag[92];
adfRPCTag[0] = -1.0; // Error Bias
adfRPCTag[1] = -1.0; // Error Random
adfRPCTag[2] = 1.231;
adfRPCTag[3] = 1.231;
adfRPCTag[4] = 11.231;
adfRPCTag[5] = 12.231;
adfRPCTag[6] = 41.231;
adfRPCTag[7] = 17.231;
adfRPCTag[8] = 16.231;
adfRPCTag[9] = 16.231;
adfRPCTag[10] = 16.231;
adfRPCTag[11] = 16.231;
for (int i = 0; i < 20; i++) {
adfRPCTag[12+i] = 1.25;
}
for (int j = 0; j < 20; j++) {
adfRPCTag[32+j] = 12.25;
}
for (int k = 0; k < 20; k++) {
adfRPCTag[52+k] = 13.25;
}
for (int s = 0; s < 20; s++) {
adfRPCTag[72+s] = 15.25;
}
TIFFSetField(tiff, TIFFTAG_RPCCOEFFICIENT, 92 ,adfRPCTag);
TIFFRewriteDirectory(tiff);
TIFFClose(tiff);
}
void ReadTAG(){
TIFF * tiff =
TIFFOpen("/home/jjmf/sample_images/OutputTIFF/input_tiff_2.tif", "r");
uint16 nCount;
if (!tiff)
{
cout << "Unable to open " << endl;
exit(0);
}
double *prueba;
TIFFGetField(tiff, TIFFTAG_RPCCOEFFICIENT, &nCount, &prueba );
for(uint16 i =0 ; i< nCount ; i++)
{
cout << prueba[i] <<endl;
}
TIFFClose(tiff);
}
int gdalRead(){
GDALAllRegister();
GDALDataset *m_poDataset;
const char * pszSrcFilename =
"/home/jjmf/sample_images/OutputTIFF/input_tiff_2.tif";
m_poDataset = (GDALDataset *) GDALOpen( pszSrcFilename, GA_ReadOnly );
if( m_poDataset == NULL )
{
cout << "Unable to open " << pszSrcFilename << endl;
return 0;
}
GDALRPCInfo sRPC;
char ** Metadata= m_poDataset->GetMetadata(NULL);
if(GDALExtractRPCInfo(Metadata, &sRPC))
{
cout << "Got RPCs Info" <<endl;
}else{
cout << "Not RPCs Info" <<endl;
}
return 1;
}
int main(int argc, char** argv) {
_ParentExtender = TIFFSetTagExtender(GTiffTagExtender);
SetTAG();
ReadTAG();
gdalRead();
return 0;
}
//--------------------------------------------------------------------------------------------------------------------
Many thanks,
Jorge
2011/5/24 Frank Warmerdam <warmerdam at pobox.com>
> On 11-05-24 12:25 PM, Jorge Martin wrote:
>
>> Many Thanks Frank, I have insert the RPCCoeffcientTag to the file.
>>
>> Is any comercial software that could read this TAG? In order
>> to
>> check the implementation I need open the file with a comercial software. I
>> have
>> tried with ENVI but it does not recognize the format.
>>
>
> Jorge,
>
> You can test with GDAL. It is commercial software since you can purchase
> commercial support for it from folks like me. Or perhaps you mean
> proprietary? Or perhaps you just mean respectible?
>
>
> 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
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/gdal-dev/attachments/20110525/4a70d2d5/attachment-0001.html
More information about the gdal-dev
mailing list