Choropleth maps
Choropleth maps also show concentration, however, they use different shades of color to show concentration. Darker colors have higher concentration and lighter colors have lower concentration. This method is useful if related data spans multiple polygons. For example, in a worldwide population density map by country, many countries have disconnected polygons (for example, Hawaii is an island state of the US). In this example, we'll use the PIL discussed in Chapter 3, The Geospatial Technology Landscape. PIL is not purely Python but is designed specifically for Python. We'll recreate our previous dot density example as a choropleth map. We'll calculate a density ratio based on the number of people (population) per square kilometer and use that value to adjust the color. Dark is more densely populated and lighter is less:
import math import shapefile import Image import ImageDraw def world2screen(bbox, w, h, x, y): """convert geospatial coordinates to pixels""" minx,miny...