O'Reilly logo

Geospatial Development By Example with Python by Pablo Carreira

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Creating color classified images

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:

  1. 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])) ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required