Creating image compositions
Now that we know the basics of iterating through the image, which allows us to process many bands together without running out of memory, let's produce some fancier results.
True color compositions
Since we have Landsat's red, green, and blue bands, we can create an image with true colors. This means an image with colors similar to what they would be if we were directly observing the scene (for example, the grass is green and the soil is brown). To do this, we will explore a little bit more of Python's iterators.
The Landsat 8 RGB bands are respectively bands 4, 3, and 2. Following the concept that we want to automate tasks and processes, we won't repeat the commands for each one of the bands. We will program Python to do this as follows:
- Edit your imports at the beginning of the file to be as follows:
import os import cv2 as cv import itertools from osgeo import gdal, gdal_array import numpy as np
- Now add this new function. It will prepare the...