PNGCanvas
Sometimes, you may find that PIL is overkill for your purposes, or you are not allowed to install PIL because you do not have administrative rights to the machine that you’re using to install Python modules that have been created and compiled in C. In those cases, you can usually get away with the lightweight pure Python PNGCanvas module.
PNGCanvas is one of the specialized libraries not included in Anaconda so we’ll have to install it using pip:
pip install pngcanvas
Using this module, we can repeat the raster shapefile example we performed using PIL but in pure Python, as you can see here:
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 r.shapes()[0].points:
     px = int(iwidth - ((r.bbox[2] - x) * xratio))
     ...