[Gdal-dev] Anyway to translate tiff into a geotiff one?
Andrey Kiselev
dron at ak4719.spb.edu
Sun Oct 19 04:12:55 EDT 2003
On Sun, Oct 19, 2003 at 02:40:17PM +0800, Fu Chen wrote:
> I have some tiff files generated from the other image processing
> programs. The tags of geography are missed. Is there anyway to fix it
> up? Is there any command can add tags on it and make it a geotiff that
> GIS application can read?
Yes, you can add missed information using GDAL, but you should excatly
know geographic parameters of the converted scene.
1. You should prepare worldfile with the geodetic coordinates of the
scene. Worldfile is a simple ASCII file with the six numbers, separated
by newlines, with the .wld suffix. Numbers meanning:
<pixel width>
<row rotation>
<column rotation>
<pixel height>
<X coordinate of the top left pixel center>
<Y coordinate of the top left pixel center>
2. You need to know, what coordinate system and projection should be
used for your scene. As soon as you got thise info you can use
gdal_translate with the -a_srs otion to convert your TIFFs.
For example, let we have unreferenced old.tif file:
$ gdalinfo old.tif
Driver: GTiff/GeoTIFF
Size is 515, 515
Coordinate System is `'
Corner Coordinates:
Upper Left ( 0.0, 0.0)
Lower Left ( 0.0, 515.0)
Upper Right ( 515.0, 0.0)
Lower Right ( 515.0, 515.0)
Center ( 257.5, 257.5)
Band 1 Block=515x15 Type=Byte, ColorInterp=Gray
Prepare a world file:
$ cat old.wld
60.0000000000
0.0000000000
0.0000000000
-60.0000000000
-15381.6153115346
15418.7591774315
I know, that input file has Albers Equal Area projection and I know
projection parameters, so now I can do following:
$ gdal_translate -a_srs "+datum=WGS84 +proj=aea \
+lat_1=33.90363402777778 +lat_2=33.62529002777778 \
+lat_0=33.76446202777777 +lon_0=-117.4745428888889" old.tif new.tif
And now we have result:
$ gdalinfo new.tif
Driver: GTiff/GeoTIFF Size is 515, 515
Coordinate System is:
PROJCS["unnamed",
GEOGCS["WGS 84",
DATUM["WGS_1984",
SPHEROID["WGS 84",6378137,298.2572235629972,
AUTHORITY["EPSG","7030"]],
AUTHORITY["EPSG","6326"]],
PRIMEM["Greenwich",0],
UNIT["degree",0.0174532925199433],
AUTHORITY["EPSG","4326"]],
PROJECTION["Albers_Conic_Equal_Area"],
PARAMETER["standard_parallel_1",33.90363402777778],
PARAMETER["standard_parallel_2",33.62529002777778],
PARAMETER["latitude_of_center",33.76446202777777],
PARAMETER["longitude_of_center",-117.4745428888889],
PARAMETER["false_easting",0],
PARAMETER["false_northing",0],
UNIT["metre",1,
AUTHORITY["EPSG","9001"]]]
Origin = (-15411.615312,15448.759177)
Pixel Size = (60.000000,-60.000000)
Corner Coordinates:
Upper Left ( -15411.615, 15448.759) (117d38'28.23"W, 33d54'13.06"N)
Lower Left ( -15411.615, -15451.241) (117d38'26.29"W, 33d37'30.16"N)
Upper Right ( 15488.385, 15448.759) (117d18'25.49"W, 33d54'13.06"N)
Lower Right ( 15488.385, -15451.241) (117d18'27.44"W, 33d37'30.16"N)
Center ( 38.3846885, -1.2408226) (117d28'26.86"W, 33d45'52.02"N)
Band 1 Block=515x15 Type=Byte, ColorInterp=Gray
Of course, all above things could be done in place, without using
intermediate files with the simple Python script.
Regards,
Andrey
--
Andrey V. Kiselev
Home phone: +7 812 5274898 ICQ# 26871517
More information about the Gdal-dev
mailing list