[Gdal-dev] Combine multiple Tiffs into a single Tiff

Paul Surgeon surgpub at telkomsa.net
Wed Oct 5 17:06:15 EDT 2005


On Wednesday 05 October 2005 22:15, Rob McCulley wrote:
> Hi,
>
> I've got a Landsat image downloaded off of Geobase.  By mistake, I
> downloaded a version with each band of landsat info in a separate GeoTiff
> (I would rather have had the bsq file, I know how to deal with it).  Can I
> use GDAL to merge three of the bands into a single RGB GeoTiff?  If not,
> what is the best way to do this?
>
> Thanks,
> Rob McCulley
> GIS Coordinator
> County of Vermilion River No. 24
> (780) 846-2244
> rmcculley at county24.com
> www.vermilion-river.ab.ca


Hi Rob

You can use VRTs to compose the bands into a single image and then use  
gdal_translate to write to a single GeoTIFF.

Example :
Here is rgb.vrt which is a plain text file.

<VRTDataset rasterXSize="8675" rasterYSize="7762">
  <SRS>PROJCS[&quot;WGS 84 / UTM zone 33N&quot;,GEOGCS[&quot;WGS 
84&quot;,DATUM[&quot;WGS_1984&quot;,SPHEROID[&quot;WGS 
84&quot;,6378137,298.2572235629972,AUTHORITY[&quot;EPSG&quot;,&quot;7030&quot;]],AUTHORITY[&quot;EPSG&quot;,&quot;6326&quot;]],PRIMEM[&quot;Greenwich&quot;,0],UNIT[&quot;degree&quot;,0.0174532925199433],AUTHORITY[&quot;EPSG&quot;,&quot;4326&quot;]],PROJECTION[&quot;Transverse_Mercator&quot;],PARAMETER[&quot;latitude_of_origin&quot;,0],PARAMETER[&quot;central_meridian&quot;,15],PARAMETER[&quot;scale_factor&quot;,0.9996],PARAMETER[&quot;false_easting&quot;,500000],PARAMETER[&quot;false_northing&quot;,0],UNIT[&quot;metre&quot;,1,AUTHORITY[&quot;EPSG&quot;,&quot;9001&quot;]],AUTHORITY[&quot;EPSG&quot;,&quot;32633&quot;]]</SRS>
  <GeoTransform>  5.7926250000000000e+05,  2.8500000000000000e+01,  
0.0000000000000000e+00,  5.5269195000000000e+06,  0.0000000000000000e+00, 
-2.8500000000000000e+01</GeoTransform>
  <Metadata>
    <MDI key="TIFFTAG_RESOLUTIONUNIT">2 (pixels/inch)</MDI>
    <MDI key="TIFFTAG_XRESOLUTION">72</MDI>
    <MDI key="TIFFTAG_YRESOLUTION">72</MDI>
    <MDI key="AREA_OR_POINT">Point</MDI>
  </Metadata>
  <VRTRasterBand dataType="Byte" band="1">
    <SimpleSource>
      <SourceFilename 
relativeToVRT="1">p189r026_7t20000802_z33_nn30.tif</SourceFilename>
      <SourceBand>1</SourceBand>
      <SrcRect xOff="0" yOff="0" xSize="8675" ySize="7762"/>
      <DstRect xOff="0" yOff="0" xSize="8675" ySize="7762"/>
    </SimpleSource>
  </VRTRasterBand>
  <VRTRasterBand dataType="Byte" band="2">
    <SimpleSource>
      <SourceFilename 
relativeToVRT="1">p189r026_7t20000802_z33_nn20.tif</SourceFilename>
      <SourceBand>1</SourceBand>
      <SrcRect xOff="0" yOff="0" xSize="8675" ySize="7762"/>
      <DstRect xOff="0" yOff="0" xSize="8675" ySize="7762"/>
    </SimpleSource>
  </VRTRasterBand>
  <VRTRasterBand dataType="Byte" band="3">
    <SimpleSource>
      <SourceFilename 
relativeToVRT="1">p189r026_7t20000802_z33_nn10.tif</SourceFilename>
      <SourceBand>1</SourceBand>
      <SrcRect xOff="0" yOff="0" xSize="8675" ySize="7762"/>
      <DstRect xOff="0" yOff="0" xSize="8675" ySize="7762"/>
    </SimpleSource>
  </VRTRasterBand>
</VRTDataset>

Then to write the VRT as a GeoTIFF :
gdal_translate rgb.vrt out.tif

Simple as that!
If you use OpenEV with the compose tool you don't have to type in all the all 
the projection and datum info and you can export directly as GeoTIFF (it just 
uses gdal in the background)

Regards
Paul



More information about the Gdal-dev mailing list