I assume that you need a separate image for each electorate? If so, I would use the following approach using python:
Read the geometry with GDAL / OGR:
Install the GDAL / OGR tools and their python bindings . Download the ESRI shapefile for election boundaries. Make sure you can read the polygon geometry using OGR:
import sys import ogr ds = ogr.Open( "/path/to/boundary/file.shp" ) if ds is None: print "Open failed.\n" sys.exit( 1 ) lyr = ds.GetLayer(0) lyr.ResetReading() feat = lyr.GetNextFeature() while feat is not None: geom = feat.GetGeometryRef() if geom is None or geom.GetGeometryType() != ogr.wkbPolygon: print "no poly geometry\n" feat = lyr.GetNextFeature() ds.Destroy()
Derive geometry using matplotlib through beautiful, descartes
Install matplotlib , shapely and descartes . Modify the above script to load each polygon into matplob through beautiful and descartes:
import sys import ogr from shapely.wkb import loads from descartes import PolygonPatch from matplotlib import pyplot ds = ogr.Open( "/path/to/boundary/file.shp" ) if ds is None: print "Open failed.\n" sys.exit( 1 ) lyr = ds.GetLayer(0) lyr.ResetReading() feat = lyr.GetNextFeature() while feat is not None: geom = feat.GetGeometryRef() if geom is None or geom.GetGeometryType() != ogr.wkbPolygon: print "no poly geometry\n" else:
Obviously, you need to fix this a bit to make it draw as you want, but the general approach should be sound.
source share