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
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] >>> ydist = r.bbox[3] - r.bbox[1] >>> iwidth = 400 >>> iheight = 600 >>> xratio = iwidth/xdist >>> yratio = iheight/ydist >>> pixels = [] >>> for x,y in...