Using PIL to visualize LIDAR data

The previous DEM images in this chapter were visualized using QGIS and OpenEV. We can also create output images in Python by introducing some new functions of the Python Imaging Library (PIL) that we didn't use in the previous chapters.

In this example, we'll use the PIL.ImageOps module, which has functions for histogram equalization and automatic contrast enhancement. We'll use PIL's fromarray() method to import the data from numpy. Let's see how close we can get to the output of the desktop GIS programs that were pictured in this chapter with the help of the following code:

import numpy as nptry: import Image import ImageOpsexcept ImportError: from PIL import Image, ImageOps# Source gridded LIDAR DEM file ...

Get Learning Geospatial Analysis with Python - Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.