If we want to display image information on a map, we must prepare a visual output of what we got. A common and efficient form of visual representation is to separate values into classes and give each class a different color. In our case, we can split the data into altitude classes. NumPy makes it easy for us. Let's write a method that can be called in the pipeline to get started:
Add a new method to the
RasterData
class:#... def colorize(self, style): """Produces an BGR image based on a style containing limits and colors. :param style: A list of limits and colors. """ shape = self.data.shape limits = [] colors = [] # Separate the limits and colors. for item in style: limits.append(item[0]) colors.append(self._convert_color(item[1])) colors = np.array(colors) # Put each color in its limits. flat_array = self.data.flatten() di_array...