Combine
Combining bands is an important step in working with satellite images, especially for creating color compositions that help highlight certain features of the surface. This process merges multiple spectral bands into one image, often using 3 bands to create a 3-channel color image. For example, combining the red, green, and blue bands allows you to create a true-color image that looks similar to what we see with our eyes from space.
However, the raw data from satellites, like surface reflectance, is usually not adjusted for good visualization. When you combine the bands, the result might look mostly black-and-white, even though 3 bands are being used. This happens because the data values need to be scaled, shifted and normalized to create a more visually appealing image.
Input Directory¤
The input directory should contain raster data files (.tif, .jp2) in a hierarchical structure. It’s important that all the band files you want to combine are located within the same folder. For example, if you want to combine band 1, band 2, and band 3, the directory structure might look like this:
input_dir/set1/20230901T123456_band1.tifinput_dir/set1/20230901T123456_band2.tifinput_dir/set1/20230901T123456_band3.tifinput_dir/set2/20230902T120000/band1.tifinput_dir/set2/20230902T120000/band2.tifinput_dir/set2/20230902T120000/band3.tif
In this case, each set corresponds to a different scene or tile, and all the bands for that scene are grouped together in the same subfolder (e.g., set1 or set2).
For the input band combination [1, 2, 3] the output will look like this:
input_dir/20230901T000000.tifinput_dir/20230902T000000.tif
The output is a flat folder hierarchie.
Parameters¤
| Name | Type | Description |
|---|---|---|
input_dir |
str |
Input directory containing GeoTIFF files. Can contain subfolders. |
output_dir |
str |
Output directory. If same as input then the original files are deleted. |
bands |
array |
You need to specify the band number that correspond to the files you wish to combine. This will depend on the naming convention used for your dataset. The SIPT library indentifies a file as band if the band number is in the filename like b01, b1 or b8A. For example, in the case of MODIS data, the band names might look like this: sur_refl_b01_1.tifsur_refl_b02_1.tifsur_refl_b8A_1.tifIf you want to combine band 1, band 2, and band 8A in this order, the band order to define would be [ 1, 2, "8A"] |