In this recipe we will show how to fill different regions of a map with different colors. We will use the PolygonParser
class from the previous recipe in order to get the geographical boundaries of the Canadian provinces and we are going to combine it with the crime severity index data from Statistics Canada available at http://www.statcan.gc.ca/pub/85-004-x/2009001/t009-eng.htm. Provinces with a darker gray (more red color in the code), will have higher crime severity index while provinces that are of a lighter gray color (more yellow in the code) will have lower crime severity index. This is illustrated in the following screenshot:
This recipe greatly relies on the Parsing data to use as region fill recipe; we suggest you read it before continuing.
The following steps show you how to color a map:
Create the
CrimeData
class that has a name, a crime severity index, and a boundaries propertyCombine the regional data from the Natural Earth (https://www...