PNGCanvas

Sometimes you may find PIL is overkilled for your purposes, or you are not allowed to install PIL because you do not have administrative rights to the machine you're using. In those cases, you can usually get away with the lightweight, pure Python PNGCanvas module. This module must be manually installed to your current working directory or site-packages directory from this page: http://the.taoofmac.com/space/projects/PNGCanvas

Note

Note the source code has a .txt extension which you must delete when you save the file.

Using this module we can repeat the raster shapefile example we performed using PIL but in pure Python:

>>> import shapefile >>> import pngcanvas >>> r = shapefile.Reader("hancock.shp") >>> xdist = r.bbox[2] - r.bbox[0] >>> ...

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