1.0 Introduction

1.1 Purpose

The purpose of this is to visualise the electoral boundaries of the constituencies, electoral figures and election results of the Singapore General Election 2015.

This will be done using R with the main packages sf, tmap and tidyverse from the data preparation phase to the final output without any manual pre or post processing.

1.2 Current visualisations

Fig1: Number focused nature of past Singapore General Election visualisation

Fig1: Number focused nature of past Singapore General Election visualisation

Fig2: Number focused nature of election visualisation

Fig2: Number focused nature of election visualisation

Fig3: Map focused nature of election visualisation

Fig3: Map focused nature of election visualisation

1.3 Proposed visualisation

Using a thematic map consisting of choropleth and proportional symbol methods to visualise the data.

Fig4: Draft visualisation using Tableau

Fig4: Draft visualisation using Tableau

1.3 Enhancing interactivity

  • Layering the data. Applying multiple layers to describe the data. The basemap provides the overall map of Singapore with the buildings, roads and estates. The shape layer outlines the constituency boundaries and areas covered. The colour shows the constituency types or electoral figures and results. Symbols shows the size of the GRC or election results.

  • Using built-in support for Leaflet from tmap to provide basic interactivity features like zoom and pan, layer selection, mouse-over/mouse-clik effects rather than the static output from tmap plot.

  • Encoding the values for select options as parameters for users to select what they want to see. Unfortunately, this cannot be done in RMarkdown documents. To further explore using Rshiny to achieve this.

2.0 Data Wrangling

2.1 Install packages

This code chunk installs the basic sf, tmap, tidyverse packages and load them into RStudio environment.

2.2 Import KML file

Import the kml file with some post-processing to extract the counstituency names from the XML field and re-order the columns so that the geometry column is at the end of the dataframe.

## Reading layer `ELD2015' from data source `C:\TEMP\Training\MITB\ISSS608-VA\ElectoralBoundary\ElectoralBoundary\data\electoral-boundary-2015-kml.kml' using driver `KML'
## Simple feature collection with 29 features and 2 fields
## geometry type:  POLYGON
## dimension:      XYZ
## bbox:           xmin: 103.599 ymin: 1.150372 xmax: 104.0975 ymax: 1.477406
## z_range:        zmin: 0 zmax: 0
## CRS:            4326

2.4 Join map and attribute files

Join map with GE results by constituency.

3.0 Basic Maps

3.2 Interactive map

The same map in interactive mode.

3.3 Adding electoral numbers

Since constituency type can be inferred by the constituency size, replace fill colour with the number of registered electors, add Esri.WorldImagery basemap and change default basemap to OpenStreetMap.

3.4 Visualisation insights

  • The number of Single Member Constituency (SMC) and Group Representation Constituency (GRC) are similar, with SMC slightly lesser at 13 vs GRC at 16, making a total of 29 constituencies.

  • Constituency size corresponds to the number of registered electors, with the two 6 member GRCs of Ang Mo Kio and Pasir Ris Punggol having the most numbers of registered electors. The exception is Chua Chu Kang, having only a 4 member GRC for otherwise a 5 member GRC for a larger sized constituency.

  • Constituency size may not correspond to the area of the constituency. West Coast has a fairly large area and yet is a 4 member GRC, while Ang Mo Kio and Pasir Ris Punggol are smaller sized constituencies with 6 member GRCs.

3.5 Interactivity features

The interactive map uses leaflet, a javascript library for interactive maps. Some of the advantages of the interactive map are:

  • Basemaps are incorporated so that we can overlay the geometries for clearer view of the boundaries of the constituencies. The use of OpenStreetMap basemap allows further identification of the buildings, estates and areas under each constituency.

  • The interactivity allows zooming into the details of the overlays and basemaps, which is important due to limited screen asset and underlying map details. Moreover, the zoom maintains high quality when zoomed in due to the vector nature of the overlays and maps, as opposed to fixed image resolution of the static map.

  • Further interactivity includes mouseover effect showing the constituency name and on-click effect showing the constituency name and fill data of number of registered electors.

3.6 Final thoughts

R allows programmatic reproducibility of the steps and data involved in making the visualisation. There are many configurable options, making the design highly customisable. Together, these allow iterations of the designs in a predictable manner.

As R is advancing rapidly, there are many package updates that introduce many new features. However, there may be depreciated features requiring constant code changes, as well as disparate features between packages or even within the package itself (eg feature disparity between view and plot mode of tmap, such as symbol support, basemap, histogram legend, etc).