Today: Interactive Choropleth World Map using Google GeoChart visualization
Authors: Rosaria Silipo & Paolo Tamagnini
Figure 1. A choropleth map is a geographical map where areas are colored, shaded, or patterned according to a corresponding calculated measure, in this case logarithmic number of 2013 population on a world map.
Today we want to draw the choropleth map as shown above. So what do we need?
- A map of the countries of the world and the corresponding numbers of population.
Our dataset is the CSV file population2013.csv and it contains a list of 214 world countries with their corresponding population numbers as of 2013.
- Import a dataset from the KNIME input data table object to be used with the Google libraries
- Transform the dataset into a Google object, define a visualization.GeoChart object named “chart”, and draw the chart with the function chart.draw(). This part is encapsulated in the DrawChart() function, which is used as a callback function when loading the Google visualization module and its corechart package.
The getScript() method from jQuery is great to load a single JS library. However when more concurrent, possibly dependent, JS libraries are needed, other load methods might be more suitable. We will talk about those in another post. Stay tuned!
Also, note that we have defined a heat map going from light blue (least populated countries) to dark blue (most populated countries).
It is common practice to use a monochromatic color scale. We chose the scale from light blue to dark blue as recommended in the “Color Brewer 2.0” web site.
The KNIME Workflow
In order to appreciate the differences in population a bit better, we could use a logarithmic scale. In this case a Math Formula node calculates log(2013) for each country to append to the original dataset.
<h1><font color="gray">Population in logarithmic numbers by world countries in 2013</font></h1>
Indeed, now, if we right-click the metanode and select its “Interactive Vew” item, we can see the same choropleth map with a gray title, exactly as in Figure 1. Also, if we execute the workflow from a KNIME WebPortal, the final web page will also contain this interactive view with choropleth and title.
Again if running on a KNIME WebPortal, this composite view translates into a web page with multiple choropleths and titles.
The final workflow is shown in Figure 5 and is also available on the EXAMPLES server under 03_Visualization/04_Geolocation/07_Choropleth_World_Map03_Visualization/04_Geolocation/07_Choropleth_World_Map* .
Figure 4. Composite view with two choropleth maps, side by side. On the left is the choropleth map based on pure numbers; on the right, it is based on logarithmic numbers. You might convene that the logarithmic scale allows for better appreciation of the difference in population numbers.
Figure 5. The workflow used to draw all those choropleths. From top to bottom, the workflow produces choropleth maps based on pure population numbers, on logarithmic population numbers, with a title, and shown side by side. This workflow is available on the KNIME EXAMPLES server under 03_Visualization/04_Geolocation/07_Choropleth_World_Map03_Visualization/04_Geolocation/07_Choropleth_World_Map* .
Summary and Next Steps
The workflow is available on the EXAMPLES server under 03_Visualization/04_Geolocation/07_Choropleth_World_Map03_Visualization/04_Geolocation/07_Choropleth_World_Map* .