I have created a patch to copy dataset and band-level metadata, following the ideas in this thread.<div><br></div><div>Set ticket <a href="http://trac.osgeo.org/gdal/ticket/3898">http://trac.osgeo.org/gdal/ticket/3898</a> - Any comments welcome.</div>
<div><br></div><div>I have not implemented Chaitanya&#39;s suggestion to scan for all sources though.</div><div><br></div><div>Etienne</div><div><br><div class="gmail_quote">On Thu, Nov 10, 2011 at 3:26 PM, Chaitanya kumar CH <span dir="ltr">&lt;<a href="mailto:chaitanya.ch@gmail.com">chaitanya.ch@gmail.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">fred,<br><br>IMO, it would be better if we transfer the metadata items when only one source dataset is present. Better yet, we could check if the metadata item matches when there are multiple sources.<br>
Also, I don&#39;t see the need to do this only in case of GTiff format.<br>
<br><div class="gmail_quote"><div><div class="h5">On Thu, Nov 10, 2011 at 4:45 PM, fred p <span dir="ltr">&lt;<a href="mailto:mapoubelle22@gmail.com" target="_blank">mapoubelle22@gmail.com</a>&gt;</span> wrote:<br></div>
</div><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div><div class="h5">
I have applied the following patch for my own needs to gdalwarp.cpp (from release 1.8.1). Maybe could it be applied in the next release with the appropriate changes?<br>Thanks for your answers.<br><br><br>791a792,818<br>
&gt; /*      Get the metadata of the first source file if it is a GeoTiff    */<br>

&gt; /*      and apply them to the destination file.                         */<br>&gt; /* -------------------------------------------------------------------- */<br>&gt;         if ( iSrc==0 &amp;&amp; pszFormat == &quot;GTiff&quot;)<br>


&gt;         {<br>&gt;             char **metadataSet=NULL;<br>&gt;             metadataSet = GDALGetMetadata(hSrcDS, &quot;&quot;);<br>&gt; <br>&gt;             if( CSLCount(metadataSet) &gt; 0 )<br>&gt;             {<br>


&gt;                 for( i = 0; metadataSet[i] != NULL; i++ )<br>&gt;                 {<br>&gt;                     char *val = CPLStrdup(strstr(metadataSet[i],&quot;=&quot;)+1);<br>&gt;                     size_t lenkey = strlen(metadataSet[i])-strlen(val);<br>


&gt;                     char *key = (char*)malloc(lenkey);<br>&gt;                     strncpy(key, metadataSet[i], lenkey);<br>&gt;                     key[lenkey-1] = &#39;\0&#39;;<br>&gt;                 <br>&gt;                     if( GDALSetMetadataItem(hDstDS, key, val, NULL) != CE_None ){<br>


&gt;                         fprintf( stderr, &quot;Ecriture du tag %s impossible&quot;, key);<br>&gt;                     }<br>&gt;                     <br>&gt;                 }<br>&gt;             }<br>&gt;         }<br>


&gt;         <br>&gt; /* -------------------------------------------------------------------- */<br><br><br><br><br><br><br><div class="gmail_quote">Le 10 novembre 2011 13:40, fred p <span dir="ltr">&lt;<a href="mailto:mapoubelle22@gmail.com" target="_blank">mapoubelle22@gmail.com</a>&gt;</span> a écrit :<div>

<div></div><div><br>
<blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hello list !<br><br>I use the gdalwarp tool to change the projection of a GeoTiff file but the most of the metadata of the source file are lost, which is not the case with the gdal_translate tool.<br>


Particularly, the following metadata are lost :<br>
  TIFFTAG_DOCUMENTNAME<br>  TIFFTAG_IMAGEDESCRIPTION<br>  TIFFTAG_SOFTWARE<br>  TIFFTAG_DATETIME<br>  TIFFTAG_ARTIST<br>  TIFFTAG_HOSTCOMPUTER<br><br>Do I miss something ?<br><br><br>The command :<br><br>gdalwarp -t_srs EPSG:4326 srcfile.tif outfile.tif<br>



<br><br>The gdalinfo output on the source file, followed by the gdalinfo output on the output file :<br><br>Driver: GTiff/GeoTIFF<br>Files: srcfile.tif<br>Size is 2500, 2500<br>Coordinate System is:<br>PROJCS[&quot;Geostationary_Satellite&quot;,<br>



    GEOGCS[&quot;GCS_unnamed ellipse&quot;,<br>        DATUM[&quot;D_unknown&quot;,<br>            SPHEROID[&quot;Unknown&quot;,6378160,298.2539162964669]],<br>        PRIMEM[&quot;Greenwich&quot;,0],<br>        UNIT[&quot;Degree&quot;,0.017453292519943295]],<br>



    PROJECTION[&quot;Geostationary_Satellite&quot;],<br>    PARAMETER[&quot;central_meridian&quot;,57],<br>    PARAMETER[&quot;satellite_height&quot;,35785846.6396],<br>    PARAMETER[&quot;false_easting&quot;,0],<br>    PARAMETER[&quot;false_northing&quot;,0],<br>



    UNIT[&quot;Meter&quot;,1]]<br>Origin = (-5620805.668447489850223,5620805.668447489850223)<br>Pixel Size = (4496.644534757992005,-4496.644534757992005)<br>Metadata:<br>  TIFFTAG_DOCUMENTNAME=documentname<br>  TIFFTAG_IMAGEDESCRIPTION=productidentification={<br>



        &quot;observedProperty&quot;:&quot;observedProperty&quot;,<br>        &quot;process&quot;:&quot;process&quot;,<br>}<br>  TIFFTAG_SOFTWARE=software<br>  TIFFTAG_DATETIME=2011:11:10 11:00:00<br>  TIFFTAG_ARTIST=artist<br>



  TIFFTAG_HOSTCOMPUTER=computer<br>  AREA_OR_POINT=Area<br>Image Structure Metadata:<br>  COMPRESSION=JPEG<br>  INTERLEAVE=BAND<br>Corner Coordinates:<br>ERROR 1: tolerance condition error<br>Upper Left  (-5620805.668, 5620805.668) <br>



ERROR 1: tolerance condition error<br>Lower Left  (-5620805.668,-5620805.668) <br>ERROR 1: tolerance condition error<br>Upper Right ( 5620805.668, 5620805.668) <br>ERROR 1: tolerance condition error<br>Lower Right ( 5620805.668,-5620805.668) <br>



Center      (   0.0000000,   0.0000000) ( 57d 0&#39;0.00&quot;E,  0d 0&#39;0.01&quot;N)<br>Band 1 Block=2500x1 Type=Byte, ColorInterp=Gray<br><br><br>The gdalinfo output on the output file :<br><br>Driver: GTiff/GeoTIFF<br>



Files: outfile.tif<br>Size is 1673, 1673<br>Coordinate System is:<br>GEOGCS[&quot;WGS 84&quot;,<br>    DATUM[&quot;WGS_1984&quot;,<br>        SPHEROID[&quot;WGS 84&quot;,6378137,298.257223563,<br>            AUTHORITY[&quot;EPSG&quot;,&quot;7030&quot;]],<br>



        AUTHORITY[&quot;EPSG&quot;,&quot;6326&quot;]],<br>    PRIMEM[&quot;Greenwich&quot;,0],<br>    UNIT[&quot;degree&quot;,0.0174532925199433],<br>    AUTHORITY[&quot;EPSG&quot;,&quot;4326&quot;]]<br>Origin = (0.000000000000000,70.000000000000000)<br>



Pixel Size = (0.059772863120143,-0.059772863120143)<br>Metadata:<br>  AREA_OR_POINT=Area<br>Image Structure Metadata:<br>  INTERLEAVE=BAND<br>Corner Coordinates:<br>Upper Left  (   0.0000000,  <a href="tel:70.0000000" value="+34700000000" target="_blank">70.0000000</a>) (  0d 0&#39;0.01&quot;E, 70d 0&#39;0.00&quot;N)<br>



Lower Left  (   0.0000000, -30.0000000) (  0d 0&#39;0.01&quot;E, 30d 0&#39;0.00&quot;S)<br>Upper Right ( 100.0000000,  <a href="tel:70.0000000" value="+34700000000" target="_blank">70.0000000</a>) (100d 0&#39;0.00&quot;E, 70d 0&#39;0.00&quot;N)<br>

Lower Right ( 100.0000000, -30.0000000) (100d 0&#39;0.00&quot;E, 30d 0&#39;0.00&quot;S)<br>

Center      (  50.0000000,  20.0000000) ( 50d 0&#39;0.00&quot;E, 20d 0&#39;0.00&quot;N)<br>Band 1 Block=1673x4 Type=Byte, ColorInterp=Gray<br><br>
        <img title="Copy Selction"><a href="http://int.ask.com/web?siteid=10000861&amp;webqsrc=999&amp;l=dis&amp;q=dust%20RGB%20composite" title="Search With Ask" target="_blank"><img></a><img title="Translate With Google">
        
</blockquote></div></div></div><br>
<br></div></div>_______________________________________________<br>
gdal-dev mailing list<br>
<a href="mailto:gdal-dev@lists.osgeo.org" target="_blank">gdal-dev@lists.osgeo.org</a><br>
<a href="http://lists.osgeo.org/mailman/listinfo/gdal-dev" target="_blank">http://lists.osgeo.org/mailman/listinfo/gdal-dev</a><span class="HOEnZb"><font color="#888888"><br></font></span></blockquote></div><span class="HOEnZb"><font color="#888888"><br>
<br clear="all"><br>-- <br>Best regards,<br>Chaitanya kumar CH.<br>
<br><a href="tel:%2B91-9494447584" value="+919494447584" target="_blank">+91-9494447584</a><br>17.2416N 80.1426E<br>
</font></span><br>_______________________________________________<br>
gdal-dev mailing list<br>
<a href="mailto:gdal-dev@lists.osgeo.org">gdal-dev@lists.osgeo.org</a><br>
<a href="http://lists.osgeo.org/mailman/listinfo/gdal-dev" target="_blank">http://lists.osgeo.org/mailman/listinfo/gdal-dev</a><br></blockquote></div><br></div>