Introduction

This lecture is designed to show you the potential for using R for spatial analysis when applied to historical questions.

You must have the following installed on your computer before we begin.

The following package must also be installed via R

The following code using the tmap package will display a chloroplethr map of unionist votes. This is adapted from Chris Brundson’s introduction to tmap which can be found at the following link. A second useful link is this tutorial on using tmap available here.

Setting a Working Directory

Open RStudio, in the console type

getwd()
## [1] "/Users/jackkavanagh/Dropbox/R"

Use the download link provided via Moodle to download the file marked ‘ConfMaps.RData’ and place this within your Working Directory folder. It is also available here.

Loading a RData file and packages

If you have successfully added the RData file to your working directory, when you load it a large number of new SpatialPolygons and Dataframes will appear in your Environment window.

The code is as follows:

load('ConfMaps.RData')

Background of the data

The data shown in these maps was collated by Neale Rooney and Jack Kavanagh from Brian Walker’s volumes and was collated into a series of csv files. These files were then ‘joined’ to the map using the program QGIS. In total 8 different maps were created, representing the 8 elections that occurred between 1885 and 1910. The 1918 election utilises a different constituency map that due to time constraints we were unable to create. In addition a map without any numeric data was added called map_orig which is there for anyone to use for future analysis.

Each map is named for the election i.e. con85 for the election of 1885, con86 for the election of 1886 and so forth. con1910_1 and con1910_2 are listed as such for the two elections held in January and December 1910 respectively. The smaller maps focusing upon Dublin City and County follow the same naming convention as shown above.

Examining the Data

The following code will display all the information contained with the map file ‘con85’. Note I’ve used the ‘head’ function to limit the information to the first 10.

head(con85@data)
##   OBJECTID          C1885  Shape_Leng Shape_Area UNION85 NAT85 TOTALVOTE8
## 0        1           Birr  242572.821 1082699772     760  3408       4168
## 1        2         Carlow  219821.038  896120432     751  4801       5552
## 2        3  College Green    9043.524    3561735      NA    NA         NA
## 3        4      Connemara 1170387.314 2082452059      NA    NA         NA
## 4        5      Cork City   84559.364  184449502    1464  6716       8180
## 5        6 Dublin Harbour   16620.841    5698525      NA    NA         NA
##   ELECT85    TURN85
## 0    5236 0.7960275
## 1    6891 0.8056886
## 2      NA        NA
## 3      NA        NA
## 4   14569 0.5614661
## 5      NA        NA

Overview Map

There is a file called ‘master_map’ this is the original constituency map without any data attached.

Map of Irish Constituencies 1885 - 1910

qtm(master_map, fill = "darkgrey", text = "C1885", title = "Map of Southern Irish Constituencies 1885 - 1910", text.size = "AREA", scale = 0.5) + tm_scale_bar()

Creating a chloroplethr map of Unionist Votes

Now as the analysis was focused upon the votes of unionists in 19th century Irish elections. It is important to compare the two elections using chloroplethr style maps which use colour to illustrate the density of the vote.

Map of Conservative and Nationalist Votes in 1885

tm_shape(con85) + tm_fill(col=c("UNION85","NAT85"), title=c("Conservative Votes in 1885", "Nationalist Votes in 1885"), colorNA = NULL, style = "cont") + tm_borders() + tm_style_col_blind()

Map of Turnout for the 1885 Election

tm_shape(con85) + tm_fill(col = "TURN85", colorNA = NULL, n=4, title = "% Turnout in 1885", style = "jenks") + tm_borders() + tm_text("C1885", size = "AREA", scale = 0.5) + tm_style_col_blind()

There is one flaw from this map that needs to be rectified and that’s the Dublin constituencies which are obscured due to the small geographical area. Therefore a small subset of the map needs to be created.

dublin85 <- subset(con85, C1885 %in% c("North/South Dublin", "South Dublin", "North Dublin", "College Green", "St Patricks", "St Stephens Green", "Dublin Harbour"))

Here is an example of a cartogram of the constituencies measuring the density of votes

tm_shape(cart85) + tm_fill(col = "TURN85", colorNA = NULL, n=4, title = "Cartogram of Percentage Turnout", style = "cont") + tm_borders() + tm_shape(coast) + tm_borders() + tm_scale_bar()

Labs for Class

Each map has the prefix ‘con’ followed by the date e.g. con85 is the election of 1885. Using the $ sign will bring up all the information stored within the map. Here’s an example for ‘Unionist’ votes in 1885.

con85$UNION85
##  [1]  760  751   NA   NA 1464   NA   NA   NA  289   NA   NA   NA   30   NA
## [15]   NA  192  314 1000  164   NA  507  635  106  255   NA   NA  952 1425
## [29]   NA   NA  467  174  541  163   NA   NA   NA 2685  366  772  252   NA
## [43]  917   NA  293  661  195 1369 3736   NA  133   NA  222  489   NA   NA
## [57]   75   NA  963  338  541  122  200   NA 1162 3334   NA  276 1779  289
## [71]  373   NA  262   NA  131  359  871

Activiy 1

Display a map using the code provided of Nationalist and Unionist votes in the elections, you can choose whichever election you wish.

Activity 2

Display a cartogram using the code provided of the 1892 election (Hint: cart is the prefix)

Activity 3

Display a map of the percentage turnout for two elections, adapting the code provided.