Version 4 (modified by dac, 9 years ago) (diff)


Creating Mosaics from Level 3 Hyperspectral Data

Using GDAL

The steps below describe an easy way of creating mosaics from mapped hyperspectral files, making use of the command line GDAL utilities. They can be installed on Windows through OSGeo4W, and are available on Linux through the package manager (e.g., yum, apt-get).

The initial mosaic is a 'virtual raster', which comprises a text file with links to other files containing the data. It is created using the gdalbuildvrt command, available with GDAL and also in QGIS through the Raster, Miscellaneous menu.

gdalbuildvrt -srcnodata 0 f216_mosaic.vrt /path/to/file/f216073b_mapped_osng.bil /path/to/file/f216083b_mapped_osng.bil

The above command creates a virtual raster 'f216_mosaic.vrt' from two bil files, setting the no-data value to 0. The full path to each BIL file is passed in so they are stored in the VRT (useful if the VRT file is moved). You can also create a VRT from all '.bil' files using:

gdalbuildvrt -srcnodata 0 f216_mosaic.vrt /path/to/file/*.bil

The VRT file can be used as any other file in programs which use GDAL (e.g., QGIS, ArcGIS, TuiView). However, for displaying it is often more convenient to create band / spatial subsets using the gdal_translate, also available through QGIS under Raster, Conversion, Translate.

command. For example to create a three band subset using bands 38, 25 and 12 use:

gdal_translate -of GTiff -b 38 -b 25 -b 12 f216_mosaic.vrt f216_mosaic_bandsubset.tif

Note, as all the flightlines use a slightly different grid a nearest neighbour interpolation will be preformed to create a common grid. Standard GeoTiff's aren't compressed so areas outside the flightlines, which have no data, will take up as much space as pixels with data. You can reduce the file size by using compression. You can tell gdal_translate to create a compressed GeoTiff by passing in a creation option flag for example:

gdal_translate -of GTiff -co "COMPRESS=LZW" -b 38 -b 25 -b 12 f216_mosaic.vrt f216_mosaic_bandsubset.tif

Note, not all programs support compressed GeoTiffs.

To make the mosaic faster to display you can create overviews using the gdaladdo command:

gdaladdo f216_mosaic_bandsubset.tif 2 4 8 16