Hello Frank,<div><br></div><div>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.</div>
<div><br></div><div><br></div><div>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.</div>
<div><br></div><div><br></div><div>//--------------------------------------------------------------------------------------------------------------------</div><div>#define TIFFTAG_RPCCOEFFICIENT 50844</div><div><br></div>
<div><div>static TIFFExtendProc _ParentExtender = NULL;</div><div><br></div><div>static void GTiffTagExtender(TIFF *tif)</div><div><br></div><div>{</div><div> static const TIFFFieldInfo xtiffFieldInfo[] = {</div><div> { TIFFTAG_RPCCOEFFICIENT, -1,-1, TIFF_DOUBLE,<span class="Apple-tab-span" style="white-space:pre">        </span>FIELD_CUSTOM,</div>
<div> TRUE,<span class="Apple-tab-span" style="white-space:pre">        </span>TRUE,<span class="Apple-tab-span" style="white-space:pre">        </span>(char*) "RPCCoefficient" }</div><div> };</div><div><br></div>
<div> if (_ParentExtender)</div><div> (*_ParentExtender)(tif);</div><div><br></div><div> TIFFMergeFieldInfo( tif, xtiffFieldInfo,</div><div><span class="Apple-tab-span" style="white-space:pre">                </span> sizeof(xtiffFieldInfo) / sizeof(xtiffFieldInfo[0]) );</div>
<div>}</div></div><div><br></div><div><div>void SetTAG(){</div><div><br></div><div> TIFF * tiff = TIFFOpen("/home/jjmf/sample_images/OutputTIFF/input_tiff_2.tif", "r+");</div><div><br></div><div> if (!tiff)</div>
<div> {</div><div> cout << "Unable to open " << endl;</div><div> exit(0);</div><div> }</div><div><br></div><div> double adfRPCTag[92];</div><div><br></div><div><br></div>
<div> adfRPCTag[0] = -1.0; // Error Bias</div><div> adfRPCTag[1] = -1.0; // Error Random</div><div><br></div><div><br></div><div> adfRPCTag[2] = 1.231;</div><div> adfRPCTag[3] = 1.231;</div><div> adfRPCTag[4] = 11.231;</div>
<div> adfRPCTag[5] = 12.231;</div><div> adfRPCTag[6] = 41.231;</div><div> adfRPCTag[7] = 17.231;</div><div> adfRPCTag[8] = 16.231;</div><div> adfRPCTag[9] = 16.231;</div><div> adfRPCTag[10] = 16.231;</div><div>
adfRPCTag[11] = 16.231;</div><div><br></div><div> for (int i = 0; i < 20; i++) {</div><div> adfRPCTag[12+i] = 1.25;</div><div> }</div><div><br></div><div> for (int j = 0; j < 20; j++) {</div><div> adfRPCTag[32+j] = 12.25;</div>
<div> }</div><div><br></div><div> for (int k = 0; k < 20; k++) {</div><div> adfRPCTag[52+k] = 13.25;</div><div> }</div><div><br></div><div><br></div><div> for (int s = 0; s < 20; s++) {</div><div> adfRPCTag[72+s] = 15.25;</div>
<div> }</div><div><br></div><div><br></div><div> TIFFSetField(tiff, TIFFTAG_RPCCOEFFICIENT, 92 ,adfRPCTag);</div><div><br></div><div> TIFFRewriteDirectory(tiff);</div><div><br></div><div> TIFFClose(tiff);</div><div>
<br></div><div>}</div><div><br></div><div>void ReadTAG(){</div><div><br></div><div><br></div><div> TIFF * tiff = TIFFOpen("/home/jjmf/sample_images/OutputTIFF/input_tiff_2.tif", "r");</div><div> uint16 nCount;</div>
<div> if (!tiff)</div><div> {</div><div> cout << "Unable to open " << endl;</div><div> exit(0);</div><div> }</div><div><br></div><div> </div><div> double *prueba;</div>
<div><br></div><div> TIFFGetField(tiff, TIFFTAG_RPCCOEFFICIENT, &nCount, &prueba );</div><div><br></div><div> for(uint16 i =0 ; i< nCount ; i++)</div><div> {</div><div> cout << prueba[i] <<endl;</div>
<div> }</div><div><br></div><div> TIFFClose(tiff);</div><div><br></div><div>}</div><div><br></div><div>int gdalRead(){</div><div><br></div><div> GDALAllRegister();</div><div><br></div><div> GDALDataset *m_poDataset;</div>
<div> const char * pszSrcFilename = "/home/jjmf/sample_images/OutputTIFF/input_tiff_2.tif";</div><div><br></div><div> m_poDataset = (GDALDataset *) GDALOpen( pszSrcFilename, GA_ReadOnly );</div><div> if( m_poDataset == NULL )</div>
<div> {</div><div> cout << "Unable to open " << pszSrcFilename << endl;</div><div> return 0;</div><div> }</div><div><br></div><div> GDALRPCInfo sRPC;</div><div><br></div>
<div> char ** Metadata= m_poDataset->GetMetadata(NULL);</div><div><br></div><div> if(GDALExtractRPCInfo(Metadata, &sRPC))</div><div> {</div><div> cout << "Got RPCs Info" <<endl;</div>
<div> }else{</div><div> cout << "Not RPCs Info" <<endl;</div><div><br></div><div> }</div><div> return 1;</div><div><br></div><div>}</div><div><br></div><div><br></div><div>int main(int argc, char** argv) {</div>
<div><br></div><div> _ParentExtender = TIFFSetTagExtender(GTiffTagExtender);</div><div><br></div><div> SetTAG();</div><div><br></div><div> ReadTAG();</div><div><br></div><div> gdalRead();</div><div><br></div><div>
<br></div><div> return 0;</div><div>}</div></div><div><br></div><div>//--------------------------------------------------------------------------------------------------------------------</div><div><br></div><div><br></div>
<div>Many thanks,</div><div><br></div><div><br></div><div>Jorge</div><div><br><br><div class="gmail_quote">2011/5/24 Frank Warmerdam <span dir="ltr"><<a href="mailto:warmerdam@pobox.com">warmerdam@pobox.com</a>></span><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div class="im">On 11-05-24 12:25 PM, Jorge Martin wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Many Thanks Frank, I have insert the RPCCoeffcientTag to the file.<br>
<br>
Is any comercial software that could read this TAG? In order to<br>
check the implementation I need open the file with a comercial software. I have<br>
tried with ENVI but it does not recognize the format.<br>
</blockquote>
<br></div>
Jorge,<br>
<br>
You can test with GDAL. It is commercial software since you can purchase<br>
commercial support for it from folks like me. Or perhaps you mean<br>
proprietary? Or perhaps you just mean respectible?<div><div></div><div class="h5"><br>
<br>
Best regards,<br>
-- <br>
---------------------------------------+--------------------------------------<br>
I set the clouds in motion - turn up | Frank Warmerdam, <a href="mailto:warmerdam@pobox.com" target="_blank">warmerdam@pobox.com</a><br>
light and sound - activate the windows | <a href="http://pobox.com/~warmerdam" target="_blank">http://pobox.com/~warmerdam</a><br>
and watch the world go round - Rush | Geospatial Programmer for Rent<br>
<br>
</div></div></blockquote></div><br></div>