Back to photostream

Countries, scaled according to population

This visualisation was produced in QGIS 2.12.1, with a little help from postgres/postgis (could also be done in QGIS only).

 

Areas of each country's circle are in proportion to population.

 

How it was done

 

First of all, reprojected the Natural Earth data to epsg:3410 (a cylindrical equal area projection in meters). This is important; doing it in epsg:4326 makes countries appear bigger the further they are from the equator (areal distortion). Because degrees.

 

Next, used postgis to find the centroids and buffer them, so that the circle area is in direct proportion to population. Brought these in as CSV delimited files after exporting from pgAdminIII. The query sorted images in descending order of size, so smaller countries appear on top of larger countries.

 

Unfortunately, this projection keeps areas in scale, but distorts shapes. Some countries start to look like eggs. Oh noes!

 

Got round this by scaling the map down to a small size (a few square kilometers) and centred on null island, which removed the shape distortion, but kept the equal-area. Turned off OTF projection.

 

Flag images came from CIA World Factbook, and were used as raster Image fills. Used the FIPS code from the Natural Earth data to build the filepath to the CIA factbook images like this

 

'/tmp/factbook/flags/' || "fips" || '-lgflag.gif'

 

Because you can only scale the image width at present (I used bounds_width($geometry) in map units) I had to convert each flag into a square format using ImageMagick. Most flags are wider than they are tall, this avoids tiling the flag in each circle, at the expense of corner detail.

 

Apologies in advance to Norway - not sure what happened there. Some manual tweaking may be needed :D

27,709 views
19 faves
10 comments
Uploaded on December 9, 2015