Click to learn more about co-author Rosaria Silipo.
Click to learn more about co-author Paolo Tamagnini.
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 their populations
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.
The function chart.draw() from the Google
Charts library assumes that the first column in the data contains the
country names and the second column the population numbers. When feeding the
check JQuery dependency, since the Google
of the jQuery library.
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 on the Color Brewer 2.0 website.
View node directly to the data of the population2013.csv file, the map will be
colored light blue with only two countries (India and China) in dark blue, due
to their very large populations. This is because we are dealing with
populations in absolute numbers.
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
After re-ordering the columns so as to have the log(2013) column
containing the code above. This produces the choropleth map displayed in Figure
Note: The Google Geocoding API is loaded lazily. An internet
node. Also, the map will take a longer or shorter time to load depending on the
speed of your internet connection.
|1||<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 View” item, we can see the same choropleth map with a gray title,
exactly as in Figure 1. Also, if we execute the workflow from our WebPortal, the final web page will also
contain this interactive view with choropleth and title.
We can also go one step further and combine the two plots —
the one plot with pure numbers and the other with logarithmic numbers — and
display them side by side, each with its own title, in the same view. This is
View nodes and two Text Output nodes, placed on a 2×2 layout grid. The final
composite view is shown in Figure 4.
Again, if running on a 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_Map.
Summary and Next Steps
Today we drew a choropleth map of the world showing
the Google Charts library and color code the world map areas
according to the input numbers and countries. As a bonus, we also showed how to
add a title and/or another world map choropleth in the composite view of a
The workflow is available on the EXAMPLES server under 03_Visualization/04_Geolocation/07_Choropleth_World_Map.
Credit: Source link