PIL

The PIL was originally developed for remote sensing, but has evolved as a general image editing library for Python. Like NumPy, it is written in C for speed, but is designed specifically for Python. In addition to image creation and processing, it also has a useful raster drawing module. PIL is also available via PyPI; however, in Python 3, you may want to use the Pillow module which is an upgraded version of PIL. As you'll see in the example below, we use a Python try statement to import PIL using two possible variations depending on how you installed it.

In this example, we'll combine PyShp and PIL to rasterize the hancock shapefile from previous examples and save it as an image. We'll use a world to pixel coordinate transformation similar ...

Get Learning Geospatial Analysis with Python - Second 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.