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'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"><<a href="mailto:chaitanya.ch@gmail.com">chaitanya.ch@gmail.com</a>></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'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"><<a href="mailto:mapoubelle22@gmail.com" target="_blank">mapoubelle22@gmail.com</a>></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>
> /* Get the metadata of the first source file if it is a GeoTiff */<br>
> /* and apply them to the destination file. */<br>> /* -------------------------------------------------------------------- */<br>> if ( iSrc==0 && pszFormat == "GTiff")<br>
> {<br>> char **metadataSet=NULL;<br>> metadataSet = GDALGetMetadata(hSrcDS, "");<br>> <br>> if( CSLCount(metadataSet) > 0 )<br>> {<br>
> for( i = 0; metadataSet[i] != NULL; i++ )<br>> {<br>> char *val = CPLStrdup(strstr(metadataSet[i],"=")+1);<br>> size_t lenkey = strlen(metadataSet[i])-strlen(val);<br>
> char *key = (char*)malloc(lenkey);<br>> strncpy(key, metadataSet[i], lenkey);<br>> key[lenkey-1] = '\0';<br>> <br>> if( GDALSetMetadataItem(hDstDS, key, val, NULL) != CE_None ){<br>
> fprintf( stderr, "Ecriture du tag %s impossible", key);<br>> }<br>> <br>> }<br>> }<br>> }<br>
> <br>> /* -------------------------------------------------------------------- */<br><br><br><br><br><br><br><div class="gmail_quote">Le 10 novembre 2011 13:40, fred p <span dir="ltr"><<a href="mailto:mapoubelle22@gmail.com" target="_blank">mapoubelle22@gmail.com</a>></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["Geostationary_Satellite",<br>
GEOGCS["GCS_unnamed ellipse",<br> DATUM["D_unknown",<br> SPHEROID["Unknown",6378160,298.2539162964669]],<br> PRIMEM["Greenwich",0],<br> UNIT["Degree",0.017453292519943295]],<br>
PROJECTION["Geostationary_Satellite"],<br> PARAMETER["central_meridian",57],<br> PARAMETER["satellite_height",35785846.6396],<br> PARAMETER["false_easting",0],<br> PARAMETER["false_northing",0],<br>
UNIT["Meter",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>
"observedProperty":"observedProperty",<br> "process":"process",<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'0.00"E, 0d 0'0.01"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["WGS 84",<br> DATUM["WGS_1984",<br> SPHEROID["WGS 84",6378137,298.257223563,<br> AUTHORITY["EPSG","7030"]],<br>
AUTHORITY["EPSG","6326"]],<br> PRIMEM["Greenwich",0],<br> UNIT["degree",0.0174532925199433],<br> AUTHORITY["EPSG","4326"]]<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'0.01"E, 70d 0'0.00"N)<br>
Lower Left ( 0.0000000, -30.0000000) ( 0d 0'0.01"E, 30d 0'0.00"S)<br>Upper Right ( 100.0000000, <a href="tel:70.0000000" value="+34700000000" target="_blank">70.0000000</a>) (100d 0'0.00"E, 70d 0'0.00"N)<br>
Lower Right ( 100.0000000, -30.0000000) (100d 0'0.00"E, 30d 0'0.00"S)<br>
Center ( 50.0000000, 20.0000000) ( 50d 0'0.00"E, 20d 0'0.00"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&webqsrc=999&l=dis&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>