Example: Visualizing Custom Data on a Choropleth Map - Maple Help

Home : Support : Online Help : Statistics and Data Analysis : DataSets Package : Example: Visualizing Custom Data on a Choropleth Map

Visualizing Custom Data on a Choropleth Map

 Introduction This application generates a choropleth map visualizing the average number of children born to a woman in a number of European countries for the calendar year 2015.   Data source: Eurostat - http://ec.europa.eu/eurostat/tgm/table.do?tab=table&init=1&language=en&pcode=tsdde220 (accessed 9 April 2017) Data Description: The mean number of children that would be born alive to a woman during her lifetime if she were to survive and pass through her childbearing years conforming to the fertility rates by age of a given year.

Import fertility rate data

First a DataFrame is created to contain the data set. Note that this data is for the year 2015.

 > FertilityData := Import("datasets/fertility_rates.csv", base = datadir);
 ${\mathrm{FertilityData}}{≔}\left[\begin{array}{cc}{}& {\mathrm{Fertility Rate - 2015}}\\ {\mathrm{Belgium}}& {1.7}\\ {\mathrm{Bulgaria}}& {1.53}\\ {\mathrm{Czech Republic}}& {1.57}\\ {\mathrm{Denmark}}& {1.71}\\ {\mathrm{Germany}}& {1.5}\\ {\mathrm{Estonia}}& {1.58}\\ {\mathrm{Ireland}}& {1.92}\\ {\mathrm{Greece}}& {1.33}\\ {\mathrm{...}}& {\mathrm{...}}\end{array}\right]$ (2.1)

Generate a world map and restrict the view to Europe

The WorldMap command creates a WorldMap object that can be used to display maps of the world in various ways.

 > europeMap := DataSets:-Builtin:-WorldMap():

The SetView command restricts the view frame for the World map to a given area.

 > SetView(europeMap,-11,36,32,87):

Define the colors used to shade the map

In the following section, we define two colors to be used to generate the gradient in the ChoroplethMap.

Lowest fertility value:

 > c1 := ColorTools:-Color("RGB",[0/255,55/255,0/255]);
 ${\mathrm{c1}}{≔}{⟨}\colorbox[rgb]{0,0.215686274509804,0}{{RGB : 0 0.216 0}}{⟩}$ (4.1)

Highest fertility value:

 > c2 := ColorTools:-Color("RGB",[230/255,230/255,150/255]);
 ${\mathrm{c2}}{≔}{⟨}\colorbox[rgb]{0.901960784313726,0.901960784313726,0.588235294117647}{RGB : 0.902 0.902 0.588}{⟩}$ (4.2)

Generate a choropleth

The ChoroplethMap command generates a map that is shaded in proportion to the measurements for the displayed variable, the fertility rate. The plots:-display

 > FertilityMap := ChoroplethMap(europeMap, FertilityData, [c1, c2], mapdata=fine, watercolor="White"):