[gdal-dev] Re: lost GeoTiff file metadata with gdalwarp
Etienne Tourigny
etourigny.dev at gmail.com
Mon Mar 5 18:47:18 EST 2012
I have created a patch to copy dataset and band-level metadata, following
the ideas in this thread.
Set ticket http://trac.osgeo.org/gdal/ticket/3898 - Any comments welcome.
I have not implemented Chaitanya's suggestion to scan for all sources
though.
Etienne
On Thu, Nov 10, 2011 at 3:26 PM, Chaitanya kumar CH
<chaitanya.ch at gmail.com>wrote:
> fred,
>
> 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.
> Also, I don't see the need to do this only in case of GTiff format.
>
> On Thu, Nov 10, 2011 at 4:45 PM, fred p <mapoubelle22 at gmail.com> wrote:
>
>> 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?
>> Thanks for your answers.
>>
>>
>> 791a792,818
>> > /* Get the metadata of the first source file if it is a GeoTiff
>> */
>> > /* and apply them to the destination file.
>> */
>> > /* --------------------------------------------------------------------
>> */
>> > if ( iSrc==0 && pszFormat == "GTiff")
>> > {
>> > char **metadataSet=NULL;
>> > metadataSet = GDALGetMetadata(hSrcDS, "");
>> >
>> > if( CSLCount(metadataSet) > 0 )
>> > {
>> > for( i = 0; metadataSet[i] != NULL; i++ )
>> > {
>> > char *val = CPLStrdup(strstr(metadataSet[i],"=")+1);
>> > size_t lenkey = strlen(metadataSet[i])-strlen(val);
>> > char *key = (char*)malloc(lenkey);
>> > strncpy(key, metadataSet[i], lenkey);
>> > key[lenkey-1] = '\0';
>> >
>> > if( GDALSetMetadataItem(hDstDS, key, val, NULL) !=
>> CE_None ){
>> > fprintf( stderr, "Ecriture du tag %s
>> impossible", key);
>> > }
>> >
>> > }
>> > }
>> > }
>> >
>> > /* --------------------------------------------------------------------
>> */
>>
>>
>>
>>
>>
>>
>> Le 10 novembre 2011 13:40, fred p <mapoubelle22 at gmail.com> a écrit :
>>
>> Hello list !
>>>
>>> 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.
>>> Particularly, the following metadata are lost :
>>> TIFFTAG_DOCUMENTNAME
>>> TIFFTAG_IMAGEDESCRIPTION
>>> TIFFTAG_SOFTWARE
>>> TIFFTAG_DATETIME
>>> TIFFTAG_ARTIST
>>> TIFFTAG_HOSTCOMPUTER
>>>
>>> Do I miss something ?
>>>
>>>
>>> The command :
>>>
>>> gdalwarp -t_srs EPSG:4326 srcfile.tif outfile.tif
>>>
>>>
>>> The gdalinfo output on the source file, followed by the gdalinfo output
>>> on the output file :
>>>
>>> Driver: GTiff/GeoTIFF
>>> Files: srcfile.tif
>>> Size is 2500, 2500
>>> Coordinate System is:
>>> PROJCS["Geostationary_Satellite",
>>> GEOGCS["GCS_unnamed ellipse",
>>> DATUM["D_unknown",
>>> SPHEROID["Unknown",6378160,298.2539162964669]],
>>> PRIMEM["Greenwich",0],
>>> UNIT["Degree",0.017453292519943295]],
>>> PROJECTION["Geostationary_Satellite"],
>>> PARAMETER["central_meridian",57],
>>> PARAMETER["satellite_height",35785846.6396],
>>> PARAMETER["false_easting",0],
>>> PARAMETER["false_northing",0],
>>> UNIT["Meter",1]]
>>> Origin = (-5620805.668447489850223,5620805.668447489850223)
>>> Pixel Size = (4496.644534757992005,-4496.644534757992005)
>>> Metadata:
>>> TIFFTAG_DOCUMENTNAME=documentname
>>> TIFFTAG_IMAGEDESCRIPTION=productidentification={
>>> "observedProperty":"observedProperty",
>>> "process":"process",
>>> }
>>> TIFFTAG_SOFTWARE=software
>>> TIFFTAG_DATETIME=2011:11:10 11:00:00
>>> TIFFTAG_ARTIST=artist
>>> TIFFTAG_HOSTCOMPUTER=computer
>>> AREA_OR_POINT=Area
>>> Image Structure Metadata:
>>> COMPRESSION=JPEG
>>> INTERLEAVE=BAND
>>> Corner Coordinates:
>>> ERROR 1: tolerance condition error
>>> Upper Left (-5620805.668, 5620805.668)
>>> ERROR 1: tolerance condition error
>>> Lower Left (-5620805.668,-5620805.668)
>>> ERROR 1: tolerance condition error
>>> Upper Right ( 5620805.668, 5620805.668)
>>> ERROR 1: tolerance condition error
>>> Lower Right ( 5620805.668,-5620805.668)
>>> Center ( 0.0000000, 0.0000000) ( 57d 0'0.00"E, 0d 0'0.01"N)
>>> Band 1 Block=2500x1 Type=Byte, ColorInterp=Gray
>>>
>>>
>>> The gdalinfo output on the output file :
>>>
>>> Driver: GTiff/GeoTIFF
>>> Files: outfile.tif
>>> Size is 1673, 1673
>>> Coordinate System is:
>>> GEOGCS["WGS 84",
>>> DATUM["WGS_1984",
>>> SPHEROID["WGS 84",6378137,298.257223563,
>>> AUTHORITY["EPSG","7030"]],
>>> AUTHORITY["EPSG","6326"]],
>>> PRIMEM["Greenwich",0],
>>> UNIT["degree",0.0174532925199433],
>>> AUTHORITY["EPSG","4326"]]
>>> Origin = (0.000000000000000,70.000000000000000)
>>> Pixel Size = (0.059772863120143,-0.059772863120143)
>>> Metadata:
>>> AREA_OR_POINT=Area
>>> Image Structure Metadata:
>>> INTERLEAVE=BAND
>>> Corner Coordinates:
>>> Upper Left ( 0.0000000, 70.0000000) ( 0d 0'0.01"E, 70d 0'0.00"N)
>>> Lower Left ( 0.0000000, -30.0000000) ( 0d 0'0.01"E, 30d 0'0.00"S)
>>> Upper Right ( 100.0000000, 70.0000000) (100d 0'0.00"E, 70d 0'0.00"N)
>>> Lower Right ( 100.0000000, -30.0000000) (100d 0'0.00"E, 30d 0'0.00"S)
>>> Center ( 50.0000000, 20.0000000) ( 50d 0'0.00"E, 20d 0'0.00"N)
>>> Band 1 Block=1673x4 Type=Byte, ColorInterp=Gray
>>>
>>> <http://int.ask.com/web?siteid=10000861&webqsrc=999&l=dis&q=dust%20RGB%20composite>
>>
>>
>>
>> _______________________________________________
>> gdal-dev mailing list
>> gdal-dev at lists.osgeo.org
>> http://lists.osgeo.org/mailman/listinfo/gdal-dev
>>
>
>
>
> --
> Best regards,
> Chaitanya kumar CH.
>
> +91-9494447584
> 17.2416N 80.1426E
>
> _______________________________________________
> gdal-dev mailing list
> gdal-dev at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/gdal-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/gdal-dev/attachments/20120305/04bca092/attachment.html
More information about the gdal-dev
mailing list