This webpage is a listing of the code utilised and the process of creating the maps and visualisations created for the journal article. All the visualisations use information drawn from the IRA nominal rolls series collated as part of the Military Service Pension Collection (MSPC).
All the spatial objects, lookup tables and shapefiles are included as part of a .RData package, this file along with the csv files are available here. However, the process of creating each of these spatial objects has been set out in detail below. The following code is designed to show a user how to reproduce the visualisations and analyses outlined in the journal.
The naming conventions for this analysis has been shortened largely for ease of use, while retaining the basic definition of what is being analysed, e.g. td_names = Townlands lookup table, townlands = td etc., etc.
This analysis requires that the user has some knowledge of how to utilise programming languages such as R, however, for new users the following guide at the Programming Historian is recommended, which will walk new users through the first stages of setting up R and RStudio, installing packages and setting up a workspace.
The majority of code used for this analysis follows the Tidyverse principals set out by Hadley Wickham.1 The map projections for this journal require the tmap package developed by Martijn Tennekes. Tennekes drew upon the earlier work of Hadley Wickham and Leland Wilkinson, to create what he referred to as the layered grammar of thematic maps.2 The sf (simple features) package authored by Edzer Pebesma is also used for all the spatial objects in this journal article.3 There are a number of tutorials written by Tennekes and others, however, the most relevant for this analysis is chapter 8 of the recent publication, Geocomputation with R by Robin Lovelace, Jakub Nowosad, Jannes Muenchow which uses the sf package in conjunction with tmap.4 This book is available online and written using R here.
The first task is to set a workspace on your computer and place the following csv files from this link into the workspace. Second task is the install the libraries listed below, the following command will do this automatically:
install.packages("tmap", "tmaptools", "tidyverse", "sf", "cartogram", "viridis", "viridisLite")
Before any visualisations can be created, a number of shapefiles that will be used in this analysis need to be downloaded. (Note: These are provided in the .RData file, however, for the purposes of reproducing the data analysis, the download links are provided for each of the shapefiles).
First is the townlands shapefile from the Ordnance Survey of Ireland (OSi), this is available to download here.
Second is of electoral divisions, this will be used for the divisional mapping. This is available from the OSi at the following link.
Third is an administrative county shapefile for Ireland, that shows the historical thirty-two counties, as opposed to modern local authorities. This is drawn from the Townlands.ie website and is available here.
Fourth is a topographical shapefile of Europe from the VMap0 here
Fifth is a physiographical shapefile from the Geological Survey of Ireland. here.
Please note that the lookup tables were created using the specific OSi shapefiles above, there are revised versions available from the OSi, however, these include a number of substantial changes, in particular for the 2019 Townlands shapfile.
Note that all of these shapefiles have been used for strictly educational purposes, subject to the terms & conditions with which these files have been released to the general public.
Each lookup table utilised a match file that links townlands to their respective electoral divisions, this was used during the linking process of connecting IRA units to specific townlands and electoral divisions. The mapping schema outlines how each was linked and specifies the relevant archival file used. These files have been included for reference purposes.
Using the read.csv() command imports csv files in the R workspace and saves them as dataframes.
library(tmap)
library(tmaptools)
library(sf)
library(cartogram)
library(tidyverse)
library(viridis)
library(viridisLite)
Note All of the programming code and analysis was written and developed using R version 4.4.0 and RStudio version 2024.04.0+735.
You can either load the ‘Data_Journal.RData’ file directly or you can import the csv files and re-create the objects.
read.csv('IRA_Lookup_1921-2_td.csv',
stringsAsFactors = F,
na.strings= c("NA", " ", "")) -> td_names
read.csv('unit_strengths.csv',
stringsAsFactors = F,
na.strings= c("NA", " ", "")) -> IRA_strengths
read.csv('limerick_towns.csv',
stringsAsFactors = F,
na.strings= c("NA", " ", "")) -> limerick_towns
read.csv('MSPC_Lookup_Table_11 July 1921.csv',
stringsAsFactors = F,
na.strings= c("NA", " ", "")) -> mspc_lookup_table
Each csv file has been imported into R as a dataframe.
The MSPC lookup table outlines how each townland and electoral division was linked to IRA companies, battalions, brigades and divisions.
mspc_lookup_table %>% head(n=10)
## DATE MSPC.Listed.Geographic.Area LINKED...TD
## 1 11-7-21 Naul NAUL
## 2 11-7-21 Naul WESTOWN
## 3 11-7-21 Ring Commons RING COMMONS
## 4 11-7-21 Ring Commons RING COMMONS (1st Division)
## 5 11-7-21 Ring Commons RING COMMONS (2nd Division)
## 6 11-7-21 Skerries TOWNPARKS
## 7 11-7-21 Gormanstown GORMANSTON DEMESNE
## 8 11-7-21 Gormanstown GORMANSTON
## 9 11-7-21 Balbriggan TANKARDSTOWN
## 10 11-7-21 Balbriggan BALBRIGGAN
## LINKED...ED COMPANY BATTALION BRIGADE DIVISION COUNTY
## 1 HOLLYWOOD A Company 1st Battalion Fingal 1st Eastern Dublin
## 2 HOLLYWOOD A Company 1st Battalion Fingal 1st Eastern Dublin
## 3 BALSCADDEN B Company 1st Battalion Fingal 1st Eastern Dublin
## 4 HOLLYWOOD B Company 1st Battalion Fingal 1st Eastern Dublin
## 5 HOLLYWOOD B Company 1st Battalion Fingal 1st Eastern Dublin
## 6 SKERRIES C Company 1st Battalion Fingal 1st Eastern Dublin
## 7 BALSCADDEN D Company 1st Battalion Fingal 1st Eastern Meath
## 8 STAMULLIN D Company 1st Battalion Fingal 1st Eastern Meath
## 9 BALBRIGGAN URBAN E Company 1st Battalion Fingal 1st Eastern Dublin
## 10 BALBRIGGAN URBAN E Company 1st Battalion Fingal 1st Eastern Dublin
## COMPANY.LOOKUP BATTALION.LOOKUP BRIGADE.LOOKUP SOURCE...MSPC.Code NOTE
## 1 1 TD in ED 1 TD in ED ED linked to Brigade MSPC-RO-519-Part 1 <NA>
## 2 1 TD in ED 1 TD in ED ED linked to Brigade MSPC-RO-519-Part 1 <NA>
## 3 1 TD in ED 1 TD in ED ED linked to Brigade MSPC-RO-519-Part 1 <NA>
## 4 1 TD in ED 1 TD in ED ED linked to Brigade MSPC-RO-519-Part 1 <NA>
## 5 1 TD in ED 1 TD in ED ED linked to Brigade MSPC-RO-519-Part 1 <NA>
## 6 1 TD in ED All TDs in ED ED linked to Brigade MSPC-RO-519-Part 1 <NA>
## 7 1 TD in ED 1 TD in ED ED linked to Brigade MSPC-RO-519-Part 1 <NA>
## 8 1 TD in ED 1 TD in ED ED linked to Brigade MSPC-RO-519-Part 1 <NA>
## 9 1 TD in ED All TDs in ED ED linked to Brigade MSPC-RO-519-Part 1 <NA>
## 10 1 TD in ED All TDs in ED ED linked to Brigade MSPC-RO-519-Part 1 <NA>
From this mspc_lookup_table, a GIS lookup table was created using the match csv file that contains the townland and electoral division ID codes. This is an overview of the first 10 rows.
td_names %>% head(n=10)
## FID_1 FID_12 FID_2 OBJECTID DIVISION_22 BRIGADE_22 BATTALION_22
## 1 45606 45515 1140 2732 2nd SOUTHERN MID LIMERICK 3rd BATTALION
## 2 12544 12396 1101 2693 <NA> SOUTH SLIGO 3rd BATTALION
## 3 32321 32162 2329 1921 2nd SOUTHERN MID LIMERICK 2nd BATTALION
## 4 20610 20506 2436 28 <NA> NORTH SLIGO 3rd BATTALION
## 5 10523 10136 2436 28 <NA> NORTH SLIGO 3rd BATTALION
## 6 9405 9097 2436 28 <NA> NORTH SLIGO 3rd BATTALION
## 7 27320 27340 2436 28 <NA> NORTH SLIGO 3rd BATTALION
## 8 20611 20535 2436 28 <NA> NORTH SLIGO 3rd BATTALION
## 9 27319 27297 2436 28 <NA> NORTH SLIGO 3rd BATTALION
## 10 22828 22892 2436 28 <NA> NORTH SLIGO 3rd BATTALION
## COMPANY_22 DATE_OF_BOUNDARIES_1922 TD_ENGLISH ED_ENGLISH COUNTY
## 1 A COMPANY 01.07.1922 CASTLEMUNGRET BALLYCUMMIN LIMERICK
## 2 A COMPANY 01.07.1922 BALLYMOTE BALLYMOTE SLIGO
## 3 A COMPANY 01.07.1922 RIVERS BALLYVARRA LIMERICK
## 4 A COMPANY 01.07.1922 RATHMORE BUNDORAN RURAL DONEGAL
## 5 A COMPANY 01.07.1922 ARDFARN BUNDORAN RURAL DONEGAL
## 6 A COMPANY 01.07.1922 BALLYMUNTERHIGGIN BUNDORAN RURAL DONEGAL
## 7 A COMPANY 01.07.1922 DRUMACRIN BUNDORAN RURAL DONEGAL
## 8 A COMPANY 01.07.1922 DUNMUCKRUM BUNDORAN RURAL DONEGAL
## 9 A COMPANY 01.07.1922 FINNER BUNDORAN RURAL DONEGAL
## 10 A COMPANY 01.07.1922 MAGHERACAR BUNDORAN RURAL DONEGAL
## DATE_OF_BOUNDARIES_1921 DIVISION_21 BRIGADE_21
## 1 11.07.1921 2nd SOUTHERN MID LIMERICK
## 2 11.07.1921 <NA> SLIGO NO. 1
## 3 11.07.1921 2nd SOUTHERN MID LIMERICK
## 4 11.07.1921 <NA> SLIGO NO. 1
## 5 11.07.1921 <NA> SLIGO NO. 1
## 6 11.07.1921 <NA> SLIGO NO. 1
## 7 11.07.1921 <NA> SLIGO NO. 1
## 8 11.07.1921 <NA> SLIGO NO. 1
## 9 11.07.1921 <NA> SLIGO NO. 1
## 10 11.07.1921 <NA> SLIGO NO. 1
## BATTALION_21 COMPANY_21 TD_ID
## 1 3rd BATTALION A COMPANY 120616
## 2 3rd BATTALION A COMPANY 200131
## 3 2nd BATTALION E COMPANY 121766
## 4 10th BATTALION / 1st BATTALION (SOUTH DONEGAL) A COMPANY / B COMPANY 52258
## 5 10th BATTALION / 1st BATTALION (SOUTH DONEGAL) A COMPANY / B COMPANY 50082
## 6 10th BATTALION / 1st BATTALION (SOUTH DONEGAL) A COMPANY / B COMPANY 50261
## 7 10th BATTALION / 1st BATTALION (SOUTH DONEGAL) A COMPANY / B COMPANY 50971
## 8 10th BATTALION / 1st BATTALION (SOUTH DONEGAL) A COMPANY / B COMPANY 51176
## 9 10th BATTALION / 1st BATTALION (SOUTH DONEGAL) A COMPANY / B COMPANY 51247
## 10 10th BATTALION / 1st BATTALION (SOUTH DONEGAL) A COMPANY / B COMPANY 51836
## ED_ID PROVINCE
## 1 127018 Munster
## 2 207009 Connacht
## 3 127027 Munster
## 4 57019 Ulster
## 5 57019 Ulster
## 6 57019 Ulster
## 7 57019 Ulster
## 8 57019 Ulster
## 9 57019 Ulster
## 10 57019 Ulster
This table shows all the unit strengths per IRA company, battalion and brigade. The original files are all available for download as PDFs files from the MSPC website here.
IRA_strengths %>% head(n=10)
## BRIGADE YEAR BRIGADE_STRENGTH BATTALION BATTALION_STRENGTH COMPANY
## 1 ARIGNA 1922 1081 3rd BATTALION 144 A COMPANY
## 2 ARIGNA 1922 1081 3rd BATTALION 144 B COMPANY
## 3 ARIGNA 1922 1081 3rd BATTALION 144 C COMPANY
## 4 ARIGNA 1922 1081 3rd BATTALION 144 D COMPANY
## 5 ARIGNA 1922 1081 3rd BATTALION 144 E COMPANY
## 6 ARIGNA 1922 1081 3rd BATTALION 144 F COMPANY
## 7 ARIGNA 1922 1081 3rd BATTALION 144 G COMPANY
## 8 ARIGNA 1922 1081 4th BATTALION 155 Arigna
## 9 ARIGNA 1922 1081 4th BATTALION 155 Ballyfarnan
## 10 ARIGNA 1922 1081 4th BATTALION 155 Crossna
## COY_STRENGTH
## 1 17
## 2 19
## 3 30
## 4 20
## 5 16
## 6 21
## 7 21
## 8 NA
## 9 NA
## 10 NA
The third table is a list of long/lat columns for towns in county Limerick
limerick_towns %>% head(n=10)
## County Town Latitude Longitude
## 1 Limerick Limerick 52.66320 -8.624267
## 2 Limerick Doon 52.60365 -8.240002
## 3 Tipperary Emly 52.46344 -8.347344
## 4 Limerick Hospital 52.47449 -8.434807
## 5 Limerick Knocklong 52.43744 -8.415075
## 6 Limerick Kilfinane 52.35967 -8.466806
## 7 Limerick Garryspillane 52.41044 -8.378809
## 8 Limerick Kilmallock 52.39906 -8.567069
## 9 Limerick Bruff 52.47644 -8.544103
## 10 Limerick Meanus 52.51054 -8.611881
This is how you import each of the shapefiles as simple features or sf objects.
# Start with the Townlands file
st_read('Townland_Boundaries_Generalised_20m__OSi_National_Statutory_Boundaries/Townland_Boundaries_Generalised_20m__OSi_National_Statutory_Boundaries.shp') -> td
## Reading layer `Townland_Boundaries_Generalised_20m__OSi_National_Statutory_Boundaries' from data source `/Users/jack/Dropbox/R_Repro_IJHAC/Townland_Boundaries_Generalised_20m__OSi_National_Statutory_Boundaries/Townland_Boundaries_Generalised_20m__OSi_National_Statutory_Boundaries.shp'
## using driver `ESRI Shapefile'
## Simple feature collection with 50109 features and 12 fields
## Geometry type: MULTIPOLYGON
## Dimension: XY
## Bounding box: xmin: -10.61854 ymin: 51.41991 xmax: -5.996385 ymax: 55.43514
## Geodetic CRS: WGS 84
# Import the Electoral Division file
st_read('Electoral_Divisions__CSO_Generalised_20M/Electoral_Divisions__CSO_Generalised_20M.shp') -> ed
## Reading layer `Electoral_Divisions__CSO_Generalised_20M' from data source
## `/Users/jack/Dropbox/R_Repro_IJHAC/Electoral_Divisions__CSO_Generalised_20M/Electoral_Divisions__CSO_Generalised_20M.shp'
## using driver `ESRI Shapefile'
## Simple feature collection with 3409 features and 15 fields
## Geometry type: MULTIPOLYGON
## Dimension: XY
## Bounding box: xmin: -10.66265 ymin: 51.4199 xmax: -5.996385 ymax: 55.43514
## Geodetic CRS: WGS 84
# Import the Physiography file - Level 1 is adequate for this analysis
st_read('Physiographic_Units/SHAPEFILES/PHYSIOGRAPHY_IE_LEVEL_1.shp') -> physio_ire_1
## Reading layer `PHYSIOGRAPHY_IE_LEVEL_1' from data source
## `/Users/jack/Dropbox/R_Repro_IJHAC/Physiographic_Units/SHAPEFILES/PHYSIOGRAPHY_IE_LEVEL_1.shp'
## using driver `ESRI Shapefile'
## Simple feature collection with 905 features and 4 fields
## Geometry type: POLYGON
## Dimension: XY
## Bounding box: xmin: 417471.5 ymin: 519663.7 xmax: 734481.1 ymax: 965634.6
## Projected CRS: IRENET95 / Irish Transverse Mercator
# Import the all-Ireland administrative boundary file from Townlands.ie
st_read("counties/counties.shp") -> cty_ire
## Reading layer `counties' from data source
## `/Users/jack/Dropbox/R_Repro_IJHAC/counties/counties.shp' using driver `ESRI Shapefile'
## Simple feature collection with 32 features and 15 fields
## Geometry type: MULTIPOLYGON
## Dimension: XY
## Bounding box: xmin: -10.66262 ymin: 51.38887 xmax: -5.426816 ymax: 55.4353
## Geodetic CRS: WGS 84
# Import the VMap0 Shapefile for Europe - Elevation
st_read("eur/elev-contour-l.shp") -> europe_elevation
## Reading layer `elev-contour-l' from data source
## `/Users/jack/Dropbox/R_Repro_IJHAC/eur/elev-contour-l.shp'
## using driver `ESRI Shapefile'
## Simple feature collection with 173863 features and 9 fields
## Geometry type: LINESTRING
## Dimension: XY
## Bounding box: xmin: -31.2522 ymin: 30 xmax: 179.9994 ymax: 81.84578
## Geodetic CRS: WGS 84
# Import the VMap0 Shapefile for Europe - Elevation
st_read("eur/hydro-water-course-l.shp") -> europe_rivers
## Reading layer `hydro-water-course-l' from data source
## `/Users/jack/Dropbox/R_Repro_IJHAC/eur/hydro-water-course-l.shp'
## using driver `ESRI Shapefile'
## Simple feature collection with 200441 features and 9 fields
## Geometry type: LINESTRING
## Dimension: XY
## Bounding box: xmin: -31.26267 ymin: 30 xmax: 180 ymax: 81.19075
## Geodetic CRS: WGS 84
The sf_use_s2() often causes issues with shapefiles, particularly sf objects that are created from joins.
# Turn off the sf_use_s2(), which is the s2 package based on the google s2geometry.io library
sf::sf_use_s2(FALSE)
## Spherical geometry (s2) switched off
Use the st_join() command from sf to clip the elevation and rivers data to just show the island of Ireland. To aid the process, switch to interactive viewing before clipping so you can check your results on a live map.
# Switch to 'live' viewing
tmap_mode('view')
## tmap mode set to interactive viewing
# This will filter the elevation data to show just the island of Ireland
st_join(europe_elevation, cty_ire, left = FALSE) -> elevation_ire
## although coordinates are longitude/latitude, st_intersects assumes that they
## are planar
# Check your results
elevation_ire %>% qtm
Repeat this process for Europe rivers
# This will filter the rivers data to show just the island of Ireland
st_join(europe_rivers, cty_ire, left = FALSE) -> rivers_ire
## although coordinates are longitude/latitude, st_intersects assumes that they
## are planar
# Check your results
rivers_ire %>% qtm
For this analysis, all the Coordinate Reference Systems (CRS) were changed to the EPSG 29900 - TM65 / Irish National Grid. So we have a standardised CRS.
# Use the st_transform() command to change the CRS
td %>% st_transform(29900) -> td
ed %>% st_transform(29900) -> ed
cty_ire %>% st_transform(29900) -> cty_ire
elevation_ire %>% st_transform(29900) -> elevation_ire
rivers_ire %>% st_transform(29900) -> rivers_ire
physio_ire_1 %>% st_transform(29900) -> physio_ire_1
This creates a spatial object from the list of town coordinates in county Limerick.
st_as_sf(limerick_towns, coords = c("Longitude", "Latitude"), crs=4326) -> limerick_towns_sf
The package “Tidyverse” contains the package “dplyr” which
# Filter the physiography class using the filter() command from dplyr() and save it as a new sf object
physio_ire_1 %>% filter(Physioclas == "Water") -> physio_ire_1_water
The code for joining the the geographic lookup table to the townlands shapefile is as follows using the syntax of dplyr to join the dataframes to the shapefiles.
# This creates a linked townlands sf file with IRA lookup information
IRA_TD <- td %>% mutate(TD_ID=as.integer(as.character(TD_ID))) %>%
select(TD_ID) %>%
left_join(td_names, by="TD_ID")
Using the IRA_strengths dataframe filter for battalions and brigades.
# Create specific data frames for each Brigade population table
IRA_strengths %>% filter(BRIGADE == "WEST LIMERICK" & YEAR == "1921") -> wlim_strengths_21
IRA_strengths %>% filter(BRIGADE == "EAST LIMERICK" & YEAR == "1921") -> elim_strengths_21
IRA_strengths %>% filter(BRIGADE == "MID LIMERICK" & YEAR == "1921") -> mlim_strengths_21
# Create specific battalion totals
wlim_strengths_21 %>% select(BATTALION, BATTALION_STRENGTH) %>%
distinct(.keep_all = ) -> wlim_strengths_batts_21
elim_strengths_21 %>% select(BATTALION, BATTALION_STRENGTH) %>%
distinct(.keep_all = ) -> elim_strengths_batts_21
mlim_strengths_21 %>% select(BATTALION, BATTALION_STRENGTH) %>%
distinct(.keep_all = ) -> mlim_strengths_batts_21
# Create specific Brigade totals
wlim_strengths_21 %>% select(BRIGADE, BRIGADE_STRENGTH) %>%
distinct(.keep_all = ) -> wlim_strengths_brigs_21
elim_strengths_21 %>% select(BRIGADE, BRIGADE_STRENGTH) %>%
distinct(.keep_all = ) -> elim_strengths_brigs_21
mlim_strengths_21 %>% select(BRIGADE, BRIGADE_STRENGTH) %>%
distinct(.keep_all = ) -> mlim_strengths_brigs_21
# Select
IRA_TD %>% select(BRIGADE_21, BATTALION_21) %>%
filter(BRIGADE_21 == "WEST LIMERICK") %>%
group_by(BATTALION_21) %>% summarise() -> wlim_batts_21
IRA_TD %>% select(BRIGADE_21, BATTALION_21) %>%
filter(BRIGADE_21 == "EAST LIMERICK") %>%
group_by(BATTALION_21) %>% summarise() -> elim_batts_21
IRA_TD %>% select(BRIGADE_21, BATTALION_21) %>%
filter(BRIGADE_21 == "MID LIMERICK") %>%
group_by(BATTALION_21) %>% summarise() -> mlim_batts_21
# Select
IRA_TD %>% select(BRIGADE_21) %>%
filter(BRIGADE_21 == "WEST LIMERICK") %>%
group_by(BRIGADE_21) %>% summarise() -> wlimerick_21
IRA_TD %>% select(BRIGADE_21) %>%
filter(BRIGADE_21 == "EAST LIMERICK") %>%
group_by(BRIGADE_21) %>% summarise() -> elimerick_21
IRA_TD %>% select(BRIGADE_21) %>%
filter(BRIGADE_21 == "MID LIMERICK") %>%
group_by(BRIGADE_21) %>% summarise() -> mlimerick_21
# Create new merged shapefiles with Battalion totals
wlim_batts_totals_21 <- merge(wlim_batts_21,
wlim_strengths_batts_21,
by.x="BATTALION_21", by.y="BATTALION")
elim_batts_totals_21 <- merge(elim_batts_21,
elim_strengths_batts_21,
by.x="BATTALION_21", by.y="BATTALION")
mlim_batts_totals_21 <- merge(mlim_batts_21,
mlim_strengths_batts_21,
by.x="BATTALION_21", by.y="BATTALION")
# Create new merged shapefiles with Brigade totals
wlim_brig_total_21 <- merge(wlimerick_21,
wlim_strengths_brigs_21,
by.x="BRIGADE_21", by.y="BRIGADE")
elim_brig_total_21 <- merge(elimerick_21,
elim_strengths_brigs_21,
by.x="BRIGADE_21", by.y="BRIGADE")
mlim_brig_total_21 <- merge(mlimerick_21,
mlim_strengths_brigs_21,
by.x="BRIGADE_21", by.y="BRIGADE")
# The sf objects can be merged very easily using rbind()
rbind(elim_brig_total_21,
wlim_brig_total_21,
mlim_brig_total_21) -> limerick_brigs_21
# Check that the merged brigades
limerick_brigs_21 %>% head(n=10)
## Simple feature collection with 3 features and 2 fields
## Geometry type: MULTIPOLYGON
## Dimension: XY
## Bounding box: xmin: 107442.4 ymin: 111768 xmax: 190003.1 ymax: 167386.5
## Projected CRS: TM65 / Irish Grid
## BRIGADE_21 BRIGADE_STRENGTH geometry
## 1 EAST LIMERICK 2879 MULTIPOLYGON (((158393.8 12...
## 2 WEST LIMERICK 2511 MULTIPOLYGON (((114678.4 11...
## 3 MID LIMERICK 1862 MULTIPOLYGON (((148981.1 13...
# Create a specific bounding box for the maps of Limerick using the Limerick Brigade spatial objects
st_bbox(limerick_brigs_21) -> limerick_bbox
This will create three different types of cartograms from the cartogram package created by Sebatian Jeworutzki.5 The examples set out in the package documentation are very straightforward and easy to replicate.
# First create contiguous cartograms
wlim_batts_totals_21 %>% cartogram_cont(weight = "BATTALION_STRENGTH") -> wlim_batts_21_carto
elim_batts_totals_21 %>% cartogram_cont(weight = "BATTALION_STRENGTH") -> elim_batts_21_carto
mlim_batts_totals_21 %>% cartogram_cont(weight = "BATTALION_STRENGTH") -> mlim_batts_21_carto
# Second create non-overlapping circles cartograms (Dorling method)
wlim_batts_totals_21 %>% cartogram_dorling(weight = "BATTALION_STRENGTH") -> wlim_batts_21_carto_dorling
elim_batts_totals_21 %>% cartogram_dorling(weight = "BATTALION_STRENGTH") -> elim_batts_21_carto_dorling
mlim_batts_totals_21 %>% cartogram_dorling(weight = "BATTALION_STRENGTH") -> mlim_batts_21_carto_dorling
# Third create non-contiguous cartograms
wlim_batts_totals_21 %>% cartogram_ncont(weight = "BATTALION_STRENGTH") -> wlim_batts_21_carto_ncont
elim_batts_totals_21 %>% cartogram_ncont(weight = "BATTALION_STRENGTH") -> elim_batts_21_carto_ncont
mlim_batts_totals_21 %>% cartogram_ncont(weight = "BATTALION_STRENGTH") -> mlim_batts_21_carto_ncont
In order to create Table 1, a simple filter shows the 1st Battalion, West Limerick Brigade
mspc_lookup_table %>% filter(BRIGADE == "West Limerick" & BATTALION == "1st Battalion")
## DATE MSPC.Listed.Geographic.Area LINKED...TD LINKED...ED COMPANY
## 1 11-7-21 Monegay <NA> Monagay A Company
## 2 11-7-21 Newcastlewest <NA> Newcastle Rural B Company
## 3 11-7-21 Newcastlewest <NA> Newcastle Urban B Company
## 4 11-7-21 Killoughteen Gortboy Newcastle Urban C Company
## 5 11-7-21 Ardagh Ardagh Ardagh D Company
## 6 11-7-21 Kilcolman Kilcolman Dunmoylan East E Company
## 7 11-7-21 Carrigerry Carrigkerry Glensharrold F Company
## BATTALION BRIGADE DIVISION COUNTY COMPANY.LOOKUP
## 1 1st Battalion West Limerick 1st Southern Limerick All TDs in ED
## 2 1st Battalion West Limerick 1st Southern Limerick All TDs in ED
## 3 1st Battalion West Limerick 1st Southern Limerick 3 / 4 TDs marked
## 4 1st Battalion West Limerick 1st Southern Limerick 1 TD in ED
## 5 1st Battalion West Limerick 1st Southern Limerick 1 TD in ED
## 6 1st Battalion West Limerick 1st Southern Limerick 1 TD in ED
## 7 1st Battalion West Limerick 1st Southern Limerick 1 TD in ED
## BATTALION.LOOKUP BRIGADE.LOOKUP SOURCE...MSPC.Code
## 1 All TDs in ED ED linked to Brigade MSPC-RO-118
## 2 All TDs in ED ED linked to Brigade MSPC-RO-118
## 3 All TDs in ED ED linked to Brigade MSPC-RO-118
## 4 All TDs in ED ED linked to Brigade MSPC-RO-118
## 5 1 TD in ED 1 TD in ED MSPC-RO-118
## 6 1 TD in ED 1 TD in ED MSPC-RO-118
## 7 1 TD in ED 1 TD in ED MSPC-RO-118
## NOTE
## 1 <NA>
## 2 Newcastlewest - town over multiple EDs
## 3 Newcastlewest - town over multiple EDs
## 4 Killoughteen - village listed over 1 TD
## 5 <NA>
## 6 <NA>
## 7 <NA>
An overview of the townlands and electoral divisions shapefile of county Limerick
To create a ‘live’ view of the electoral divisions and townlands shapefiles via a tmap, change the viewing mode. For all of the maps used in this article, the tmap package was utilised, there are a number of extensive guides online and it is very adaptable for historical mapping.
# This creates a live map - the underlying basemap is from OpenStreetMaps
tmap_mode('view')
## tmap mode set to interactive viewing
First use the subset() command to select county Limerick
# Create a separate Limerick townlands sf object
subset(td, COUNTY %in% "LIMERICK") -> limerick_td
# Create a separate Limerick electoral divisions sf object
subset(ed, COUNTY %in% "LIMERICK") -> limerick_ed
# Check that it worked, use the qtm() command
limerick_td %>% qtm()
# Check that it worked, use the qtm() command
limerick_ed %>% qtm()
The ‘live’ map of county Limerick was used for the linking process, as each townland was linked to the corresponding electoral division.
# This live view shows the EDs overlaid the TDs
tm_shape(limerick_td) + tm_polygons(alpha = 0.2, col = "burlywood4") +
tm_shape(limerick_ed) + tm_borders(col = "blue")
Remember to turn off the ‘live’ map view for future maps.
# This returns a static plot map
tmap_mode('plot')
## tmap mode set to plotting
Map 1 - Distribution of Companies within 1st Battalion, West Limerick Brigade
In order to show the visualise Table 1, first create a spatial object for the West Limerick Brigade that includes the Battalions and Companies.
IRA_TD %>% select(BRIGADE_21, BATTALION_21, COMPANY_21) %>% filter(BRIGADE_21 == "WEST LIMERICK") -> wlim_brig_batts
The specify the Battalion and use the summarise() command to create the individual spatial objects.
wlim_brig_batts %>% select(BATTALION_21, COMPANY_21) %>% filter(BATTALION_21 == "1st BATTALION") %>% group_by(COMPANY_21) %>% summarise() -> wlim_batts_grp_coy
Create a West Limerick bounding box, so that the companies are easily visible. Use the wlimerick_21 spatial object of the brigade.
wlimerick_21 %>% st_bbox() -> wlimerick_bbox
In order to show county Limerick within the jurisdiction of the Republic of Ireland, first highlight the county and create a tmap object
# Create a separate sf object for Limerick
cty_ire %>% filter(NAME_TAG == "Limerick") -> limerick_cty
tm_shape(cty_ire) + tm_polygons() + tm_shape(limerick_cty) + tm_polygons(col = "blue") + tm_style("bw") -> ireland_tmap
Here is the grayscale map, showing the companies of the 1st Battalion, West Limerick Brigade.
# This is a grayscale version of the Map
tm_shape(wlim_batts_grp_coy, bbox = wlimerick_bbox) +
tm_fill(col = "COMPANY_21",
title = "IRA Companies",
palette = gray.colors(6)) +
tm_shape(cty_ire) + tm_borders() +
tm_style("bw") +
tm_layout(main.title = "Distribution of Companies, 1st Battalion, West Limerick Brigade (11 July 1921)",
main.title.size = 0.9,
main.title.position = "center",
main.title.fontfamily = "Rockwell",
frame.lwd = 0.2,
frame.double.line = TRUE,
legend.title.size = 0.7,
legend.title.fontfamily = "Rockwell",
legend.width = 0.5,
legend.position = c(-0, 1.5),
legend.just = c("LEFT", "TOP"),
bg.color = "beige") +
tm_format("World_wide", inner.margins =c(.08, .15, .10, .25)) +
tm_scale_bar(text.size = 0.6,
position = c("RIGHT", "BOTTOM"))
Here is an alternative full colour version of the map. The viridis package is used here as it produces a readable map that is designed to be viewable for multiple types of colour blindness and/or vision loss. More information about this package is available at the following link.
# This is a colour blind version of the Map
tm_shape(wlim_batts_grp_coy, bbox = wlimerick_bbox) +
tm_fill(col = "COMPANY_21",
title = "IRA Companies",
palette = "viridis") +
tm_shape(cty_ire) + tm_borders() +
tm_style("col_blind") +
tm_layout(main.title = "Distribution of Companies, 1st Battalion, West Limerick Brigade (11 July 1921)",
main.title.size = 0.9,
main.title.position = "center",
main.title.fontfamily = "Rockwell",
frame.lwd = 0.2,
frame.double.line = TRUE,
legend.title.size = 0.7,
legend.title.fontfamily = "Rockwell",
legend.width = 0.5,
legend.position = c(-0, 1.5),
legend.just = c("LEFT", "TOP"),
bg.color = "beige") +
tm_format("World_wide", inner.margins =c(.08, .15, .10, .25)) +
tm_scale_bar(text.size = 0.6,
position = c("RIGHT", "BOTTOM"))
Using colours, it is very easy to distinguish between the different companies within this battalion area. Using grayscale, the differences were less apparent, so it was necessary for the final map version, to add the name of each company to the map.
This is the final version of the map that was used for the article.
# Final Version for Article
tm_shape(wlim_batts_grp_coy, bbox = wlimerick_bbox) +
tm_fill(col = "COMPANY_21",
palette = "viridis", legend.show = F) +
tm_text("COMPANY_21",
col = "white",
size = 0.5,
ymod = -0.9,
xmod = 0,
fontfamily = "Rockwell",
just = "top") +
tm_shape(cty_ire) + tm_borders() +
tm_style("bw") +
tm_layout(frame.lwd = 0.2,
frame.double.line = TRUE,
legend.title.size = 0.7,
legend.title.fontfamily = "Rockwell",
legend.width = 0.5,
legend.position = c(-0, 1.5),
legend.just = c("LEFT", "TOP"),
bg.color = "#c0c5ce") +
tm_format("World_wide", inner.margins =c(.08, .15, .10, .25)) +
tm_scale_bar(text.size = 0.6,
position = c("RIGHT", "BOTTOM")) -> wlim_coys_tmap
Map 1
# Overlay the Ireland map
wlim_coys_tmap
print(ireland_tmap, vp = grid::viewport(0.850, 0.680, width = 0.4, height = 0.35))
Map 2 - Overview of the Limerick Brigades, IRA (11 July 1921)
# This is a black & white version of the Limerick Brigades
tm_shape(limerick_brigs_21) +
tm_fill(col = "BRIGADE_STRENGTH",
palette = gray.colors(3, gamma = 2, rev = T),
style = "fixed",
breaks =c(1500, 1800, 2100, 2400, 2700, 3000)) +
tm_text("BRIGADE_21",
col = "white",
size = 1,
ymod = -0.9,
xmod = 0,
fontfamily = "Rockwell",
just = "top") +
tm_style("bw") +
tm_legend(legend.title.size = 0.6,
legend.text.size = 0.5,
legend.position = c("LEFT", "TOP")) +
tm_add_legend(type = "line",
size = 0.5,
lwd = 1,
col = "#2f4f4f",
title = "River") +
tm_add_legend(type = "line",
size = 0.5,
lwd = 1,
col = "white",
title = "Elevation") +
tm_shape(limerick_towns_sf) + tm_dots(col = "black", size = 0.09) +
tm_text("Town",
col = "white",
size = 0.5,
ymod = -0.3,
xmod = 0,
fontfamily = "Rockwell",
just = "top") +
tm_shape(physio_ire_1_water) + tm_fill(col = "lightblue4") +
tm_shape(elevation_ire) + tm_lines(col = "white", lwd = 1, alpha = 0.6) +
tm_shape(rivers_ire) + tm_lines(col = "lightblue4") +
tm_layout(frame.lwd = 0.5,
bg.color = "gray87") +
tm_scale_bar(text.size = 0.5,
position = c("RIGHT", "BOTTOM")) +
tm_layout(inner.margins = c(0.04,0.04,0.04,0.04),
outer.margins=c(0,0,0,0))
A colour-blind friendly version of Map 2.
# This is colour version of the Limerick Brigades
tm_shape(limerick_brigs_21) +
tm_fill(col = "BRIGADE_STRENGTH",
palette = "viridis",
style = "fixed",
breaks =c(1500, 1800, 2100, 2400, 2700, 3000)) +
tm_text("BRIGADE_21",
col = "white",
size = 1,
ymod = -0.9,
xmod = 0,
fontfamily = "Rockwell",
just = "top") +
tm_style("col_blind") +
tm_legend(legend.title.size = 0.6,
legend.text.size = 0.5,
legend.position = c("LEFT", "TOP")) +
tm_add_legend(type = "line",
size = 0.5,
lwd = 1,
col = "#65737e",
title = "River") +
tm_add_legend(type = "line",
size = 0.5,
lwd = 1,
col = "white",
title = "Elevation") +
tm_shape(limerick_towns_sf) + tm_dots(col = "black", size = 0.09) +
tm_text("Town",
col = "white",
size = 0.5,
ymod = -0.1,
xmod = 0,
fontfamily = "Rockwell",
just = "top") +
tm_shape(physio_ire_1_water) + tm_fill(col = "#65737e") +
tm_shape(elevation_ire) + tm_lines(col = "white", lwd = 1, alpha = 0.3) +
tm_shape(rivers_ire) + tm_lines(col = "#65737e") +
tm_layout(frame.lwd = 0.5,
bg.color = "#c0c5ce") +
tm_scale_bar(text.size = 0.5,
position = c("RIGHT", "BOTTOM")) +
tm_layout(inner.margins = c(0.04,0.04,0.04,0.04),
outer.margins=c(0,0,0,0))
Map 3 - East Limerick Brigade - Comparison of Battalion Areas and Choropleth of Battalion Strengths
# Map 3 (a) - Grayscale
tm_shape(elim_batts_totals_21, bbox = limerick_bbox) +
tm_fill(col = "BATTALION_21",
palette = gray.colors(4, gamma = 2),
title = "Battalion Name") +
tm_style("bw") +
tm_shape(cty_ire) + tm_borders() +
tm_shape(limerick_towns_sf) + tm_dots(col = "black", size = 0.09) +
tm_text("Town",
col = "black",
size = 0.3,
ymod = -0.3,
xmod = 0,
fontfamily = "Rockwell",
just = "top") +
tm_shape(physio_ire_1_water) + tm_fill(col = "#778899") +
tm_shape(elevation_ire) + tm_lines(col = "white", lwd = 1, alpha = 0.3) +
tm_add_legend(type = "line",
size = 0.5,
lwd = 1,
col = "black",
title = "County Borders") +
tm_layout(bg.color = "#c0c5ce",
panel.labels = "(a) Battalion Areas (East Limerick Brigade)",
panel.label.size = 0.5,
panel.label.fontfamily = "Rockwell",
legend.title.size = 0.6,
legend.text.size = 0.5,
legend.position = c("LEFT", "TOP")) +
tm_scale_bar(text.size = 0.5,
position = c("RIGHT", "BOTTOM")) +
tm_layout(inner.margins = c(0.04,0.04,0.04,0.04),
outer.margins=c(0,0,0,0))
# Map 3 (b) - Grayscale
tm_shape(elim_batts_totals_21, bbox = limerick_bbox) +
tm_fill(col = "BATTALION_STRENGTH",
palette = gray.colors(4, gamma = 2, rev = T),
title = "No. of Men",
style = "fixed",
breaks = c(250, 350, 450, 550, 650)) + tm_style("bw") +
tm_shape(cty_ire) + tm_borders() +
tm_shape(limerick_towns_sf) + tm_dots(col = "black", size = 0.09) +
tm_text("Town",
col = "black",
size = 0.3,
ymod = -0.3,
xmod = 0,
fontfamily = "Rockwell",
just = "top") +
tm_shape(physio_ire_1_water) + tm_fill(col = "#4682B4") +
tm_shape(elevation_ire) + tm_lines(col = "white", lwd = 1, alpha = 0.3) +
tm_add_legend(type = "line",
size = 0.5,
lwd = 1,
col = "black",
title = "County Borders") +
tm_legend(legend.title.size = 0.6,
legend.text.size = 0.5,
legend.position = c("LEFT", "TOP")) +
tm_add_legend(type = "line",
size = 0.5,
lwd = 1,
col = "white",
title = "Elevation") +
tm_layout(bg.color = "#c0c5ce",
panel.labels = "(b) Choropleth of Battalion Strengths (East Limerick Brigade)",
panel.label.size = 0.5,
panel.label.fontfamily = "Rockwell",
legend.title.size = 0.6,
legend.text.size = 0.5,
legend.position = c("LEFT", "TOP")) +
tm_scale_bar(text.size = 0.5,
position = c("RIGHT", "BOTTOM")) +
tm_layout(inner.margins = c(0.04,0.04,0.04,0.04),
outer.margins = c(0,0,0,0))
Here are full colour verions of Map 3 (a-b)
# Map 3 (a)
tm_shape(elim_batts_totals_21, bbox = limerick_bbox) +
tm_fill(col = "BATTALION_21",
palette = "viridis",
title = "Battalion Name") +
tm_style("col_blind") +
tm_shape(cty_ire) + tm_borders() +
tm_shape(limerick_towns_sf) + tm_dots(col = "black", size = 0.09) +
tm_text("Town",
col = "black",
size = 0.3,
ymod = -0.3,
xmod = 0,
fontfamily = "Rockwell",
just = "top") +
tm_shape(physio_ire_1_water) + tm_fill(col = "#4682B4") +
tm_shape(elevation_ire) + tm_lines(col = "burlywood4", lwd = 1, alpha = 0.3) +
tm_shape(rivers_ire) + tm_lines(col = "#4682B4") +
tm_add_legend(type = "line",
size = 0.5,
lwd = 1,
col = "black",
title = "County Borders") +
tm_layout(bg.color = "#c0c5ce",
panel.labels = "(a) Battalion Areas (East Limerick Brigade)",
panel.label.size = 0.5,
panel.label.fontfamily = "Rockwell",
legend.title.size = 0.6,
legend.text.size = 0.5,
legend.position = c("LEFT", "TOP")) +
tm_scale_bar(text.size = 0.5,
position = c("RIGHT", "BOTTOM"))
# Map 3 (b)
tm_shape(elim_batts_totals_21, bbox = limerick_bbox) +
tm_fill(col = "BATTALION_STRENGTH",
palette = "cividis",
title = "No. of Men",
style = "fixed",
breaks = c(250, 350, 450, 550, 650)) + tm_style("col_blind") +
tm_shape(cty_ire) + tm_borders() +
tm_shape(limerick_towns_sf) + tm_dots(col = "black", size = 0.09) +
tm_text("Town",
col = "black",
size = 0.3,
ymod = -0.3,
xmod = 0,
fontfamily = "Rockwell",
just = "top") +
tm_shape(physio_ire_1_water) + tm_fill(col = "#4682B4") +
tm_shape(elevation_ire) + tm_lines(col = "burlywood4", lwd = 1, alpha = 0.3) +
tm_shape(rivers_ire) + tm_lines(col = "#4682B4") +
tm_add_legend(type = "line",
size = 0.5,
lwd = 1,
col = "black",
title = "County Borders") +
tm_layout(bg.color = "#c0c5ce",
panel.labels = "(b) Choropleth of Battalion Strengths (East Limerick Brigade)",
panel.label.size = 0.5,
panel.label.fontfamily = "Rockwell",
legend.title.size = 0.6,
legend.text.size = 0.5,
legend.position = c("LEFT", "TOP")) +
tm_scale_bar(text.size = 0.5,
position = c("RIGHT", "BOTTOM"))
Map 4 - Comparative Cartograms of the East Limerick Brigade, IRA (11 July 1921)
Each cartogram was created and saved a tmap, these were then diplayed consecutively using tmap_arrange()
# Map 4 (a) Continuous Cartogram
tm_shape(elim_batts_21_carto) +
tm_fill(col = "BATTALION_STRENGTH",
title = "No. of Men",
style = "fixed",
palette = gray.colors(4, gamma = 2, rev = T),
breaks = c(250, 350, 450, 550, 650)) +
tm_style("col_blind") +
tm_shape(cty_ire) + tm_borders() +
tm_shape(limerick_towns_sf) + tm_dots(col = "black", size = 0.09) +
tm_text("Town",
col = "black",
size = 0.5,
ymod = -0.1, xmod = 0,
fontfamily = "Rockwell",
just = "top") +
tm_layout(bg.color = "#c0c5ce",
panel.labels = "(a) Continuous Cartogram - Battalions within East Limerick Brigade",
panel.label.size = 0.5,
panel.label.fontfamily = "Rockwell",
legend.title.size = 0.6,
legend.text.size = 0.5,
legend.position = c("LEFT", "TOP"),
frame = T)
# Map 4 (b) Dorling Cartogram
tm_shape(elim_batts_21_carto_dorling) +
tm_fill(col = "BATTALION_STRENGTH",
title = "No. of Men",
style = "fixed",
palette = gray.colors(4, gamma = 2, rev = T),
breaks = c(250, 350, 450, 550, 650)) +
tm_style("col_blind") +
tm_shape(cty_ire) + tm_borders() +
tm_shape(limerick_towns_sf) + tm_dots(col = "black", size = 0.09) +
tm_text("Town",
col = "black",
size = 0.5,
ymod = -0.1,
xmod = 0,
fontfamily = "Rockwell",
just = "top") +
tm_layout(bg.color = "#c0c5ce",
panel.labels = "(b) Dorling Area Cartogram - Battalions within East Limerick Brigade",
panel.label.size = 0.5,
panel.label.fontfamily = "Rockwell",
legend.title.size = 0.6,
legend.text.size = 0.5,
legend.position = c("LEFT", "TOP"),
frame = T)
# Map 4 (c) Non-Contiguous Cartogram
tm_shape(elim_batts_21_carto_ncont) +
tm_fill(col = "BATTALION_STRENGTH",
title = "No. of Men",
style = "fixed",
palette = gray.colors(4, gamma = 2, rev = T),
breaks = c(250, 350, 450, 550, 650)) +
tm_style("col_blind") +
tm_shape(cty_ire) + tm_borders() +
tm_shape(limerick_towns_sf) + tm_dots(col = "black", size = 0.09) +
tm_text("Town",
col = "black",
size = 0.5,
ymod = -0.1, xmod = 0,
fontfamily = "Rockwell",
just = "top") +
tm_layout(bg.color = "#c0c5ce",
panel.labels = "(c) Noncontiguous Cartogram - Battalions within East Limerick Brigade",
panel.label.size = 0.5,
panel.label.fontfamily = "Rockwell",
legend.title.size = 0.6,
legend.text.size = 0.5,
legend.position = c("LEFT", "TOP"),
frame = T)
Hadley Wickham, ‘Tidy Data’ in Journal of Statistical Software, vol. 59, no. 10 (April 2014).↩︎
Martijn Tennekes, ‘tmap: Thematic Maps in R’ in Journal of Statistical Software, vol. 84, no. 6 (April 2018), p. 2.↩︎
Edzer Pebesma, ‘Simple Features for R: Standardized support for spatial vector data’ in R Journal, vol. 10, no. 1 (July 2018).↩︎
Robin Lovelace, Jakub Nowosad and Jannes Muenchow Geocomputation with R (2020) (https://geocompr.robinlovelace.net).↩︎
Sebastian Jeworutzki, R package: ‘cartogram’ (https://cran.r-project.org/web/packages/cartogram/index.html).↩︎