Last updated: 2020-12-14
Checks: 7 0
Knit directory: GeoPKO/
This reproducible R Markdown analysis was created with workflowr (version 1.6.2). The Checks tab describes the reproducibility checks that were applied when the results were created. The Past versions tab lists the development history.
Great! Since the R Markdown file has been committed to the Git repository, you know the exact version of the code that produced these results.
Great job! The global environment was empty. Objects defined in the global environment can affect the analysis in your R Markdown file in unknown ways. For reproduciblity it’s best to always run the code in an empty environment.
The command set.seed(20200629)
was run prior to running the code in the R Markdown file. Setting a seed ensures that any results that rely on randomness, e.g. subsampling or permutations, are reproducible.
Great job! Recording the operating system, R version, and package versions is critical for reproducibility.
Nice! There were no cached chunks for this analysis, so you can be confident that you successfully produced the results during this run.
Great job! Using relative paths to the files within your workflowr project makes it easier to run your code on other machines.
Great! You are using Git for version control. Tracking code development and connecting the code version to the results is critical for reproducibility.
The results in this page were generated with repository version 4208614. See the Past versions tab to see a history of the changes made to the R Markdown and HTML files.
Note that you need to be careful to ensure that all relevant files for the analysis have been committed to Git prior to generating the results (you can use wflow_publish
or wflow_git_commit
). workflowr only checks the R Markdown file, but you know if there are other scripts or data files that it depends on. Below is the status of the Git repository when the results were generated:
Ignored files:
Ignored: .Rhistory
Ignored: .Rproj.user/
Note that any generated files, e.g. HTML, png, CSS, etc., are not included in this status report because it is ok for generated content to have uncommitted changes.
These are the previous versions of the repository in which changes were made to the R Markdown (analysis/merge.Rmd
) and HTML (docs/merge.html
) files. If you’ve configured a remote Git repository (see ?wflow_git_remote
), click on the hyperlinks in the table below to view the files as they were in that past version.
File | Version | Author | Date | Message |
---|---|---|---|---|
Rmd | 9408512 | Nguyen Ha | 2020-12-14 | revising merge script for views; prebuild |
html | 9408512 | Nguyen Ha | 2020-12-14 | revising merge script for views; prebuild |
Rmd | 9652a69 | Tanushree Rao | 2020-12-14 | merge page update v2 including labels only for deployments and updating text to clarify |
Rmd | 74c5349 | Tanushree Rao | 2020-12-14 | merge page update v1 with troops averaged over prioid |
html | 885e0d5 | Nguyen Ha | 2020-12-09 | Build site. |
Rmd | 18bad54 | Nguyen Ha | 2020-12-09 | updating nav bar |
html | 263d508 | Nguyen Ha | 2020-12-09 | Build site. |
html | 045b912 | Nguyen Ha | 2020-12-09 | Build site. |
Rmd | 3059f09 | Nguyen Ha | 2020-12-09 | merged, also fixed outwidth |
html | 3059f09 | Nguyen Ha | 2020-12-09 | merged, also fixed outwidth |
Rmd | d436446 | Tanushree Rao | 2020-12-09 | fixing issues with old and new merge page |
Rmd | 7a7271b | Nguyen Ha | 2020-12-09 | merging gallery |
Rmd | 3c91f39 | Nguyen Ha | 2020-12-09 | commit before pulling to build |
html | 3c91f39 | Nguyen Ha | 2020-12-09 | commit before pulling to build |
Rmd | 6a20fd9 | Lou van Roozendaal | 2020-12-04 | update global animated map |
html | c0b0ce3 | Nguyen Ha | 2020-12-03 | Build site. |
Rmd | ee18491 | Nguyen Ha | 2020-12-03 | minor edit |
html | a966566 | Nguyen Ha | 2020-12-03 | Build site. |
Rmd | eafa002 | Nguyen Ha | 2020-12-03 | adapting to new dataset version |
Rmd | 5502ba6 | Lou van Roozendaal | 2020-11-26 | UpdateUCDP |
Rmd | c69de3a | Tanushree Rao | 2020-11-25 | minor text updates + removing warning messages |
Rmd | 7cd68d8 | Tanushree Rao | 2020-11-25 | minor edits, removing warning messages |
html | acee4ed | Nguyen Ha | 2020-11-25 | Build site. |
Rmd | b6fea7a | Nguyen Ha | 2020-11-25 | Revised viz, index, incorporated merge attempt 2.rmd |
html | 2011bda | Nguyen Ha | 2020-11-25 | Build site. |
Rmd | 448b94c | Nguyen Ha | 2020-11-25 | Revised viz, index, incorporated merge.rmd |
Rmd | ad652a3 | Tanushree Rao | 2020-11-24 | changed ref to geopko so it opens with v1 data |
Rmd | 6d15379 | Tanushree Rao | 2020-11-24 | updating merge page with new data |
Rmd | 2608fc0 | Tanushree Rao | 2020-09-10 | merge file |
Rmd | 9174a7c | Tanushree Rao | 2020-09-09 | adding kables |
Rmd | 113774e | Tanushree Rao | 2020-09-04 | edits to data |
Rmd | 5afdf38 | Tanushree Rao | 2020-09-03 | adding merge page |
This page shows how to merge Geo-PKO data with conflict data and visualise the results. The examples used here are Uppsala University’s Violence Early Warning System (ViEWS) project, which forecasts conflict risk, and the Uppsala Conflict Data Programme (UCDP), one of the world’s leading sources of data on armed conflict. Merging these datasets can provide insights into the links between conflict risk and peacekeeping deployments, and help policymakers make effective peacekeeping decisions where the risk of conflict is high.
Load packages.
library(dplyr)
library(tidyr)
library(geojsonio)
library(broom)
library(rgdal)
library(leaflet)
library(sp)
library(sf)
library(ggplot2)
library(spdep)
library(rjson)
library(RJSONIO)
library(rmapshaper)
library(htmltools)
library(htmlwidgets)
library(leaflet.providers)
library(kableExtra)
Our goal is to show peacekeeping deployments in 2019 and predicted conflict risks for July 2020 – six months later. It helps us visualise conflict forecasts for locations where peacekeepers are deployed and better understand the relationship between peacekeeping deployments and conflict risk.
First, we import the datasets. We’re using the published Geo-PKO dataset version 2.0, and conflict forecast data from ViEWS. The latter includes the predicted risks for state-based conflict, non-state conflict, and one-sided violence in Africa, starting from July 2020 and spanning over the next 36 months. ViEWS’ data is collected by each PRIO-grid – an innovative geospatial unit from the Peace Research Institute Oslo that divides the world into roughly 100km x 100km squares, allowing geographic analysis beyond the country level to be streamlined.
library(readr)
geopko <- readr::read_csv("data/Geo_PKO_v.2.0.csv")
#unzip("data/ViEWS.zip", exdir="data/ViEWS")
predictors <- read.csv("data/ViEWS/ensemble_pgm.csv")
The Geo-PKO dataset includes detail on troop deployment numbers, types of troops, non-troop deployments, and contributing countries.
kable(geopko[9546:9555,]) %>% kable_styling() %>%
scroll_box(width = "100%", height = "400px")
source | mission | year | month | location | geosplit | country | latitude | longitude | old_xy | geocomment | zone.de.confidence | battalion | company | platoon | other.size | comment.on.unit | no.troops | rpf | rpf.no | inf | inf.no | fpu | fpu.no | res | res.no | fp | fp.no | eng | sig | trans | riv | he.sup | sf | med | maint | recon | avia | mp | demining | uav | obs.base | cantonment | disarmament | other.type | armor | he.sup.lw | troop.type | no.tcc | nameoftcc_1 | notroopspertcc_1 | nameoftcc_2 | notroopspertcc_2 | nameoftcc_3 | notroopspertcc_3 | nameoftcc_4 | notroopspertcc_4 | nameoftcc_5 | notroopspertcc_5 | nameoftcc_6 | notroopspertcc_6 | nameoftcc_7 | notroopspertcc_7 | nameoftcc_8 | notroopspertcc_8 | nameoftcc_9 | notroopspertcc_9 | nameoftcc_10 | notroopspertcc_10 | nameoftcc_11 | notroopspertcc_11 | nameoftcc_12 | notroopspertcc_12 | nameoftcc_13 | notroopspertcc_13 | nameoftcc_14 | notroopspertcc_14 | nameoftcc_15 | notroopspertcc_15 | nameoftcc_16 | notroopspertcc_16 | nameoftcc_17 | notroopspertcc_17 | unpol.dummy | unmo.dummy | coding quality for UNMO (1=unsure; 0=perfectly fine) | hq | lo | jmco | security.group.dummy | comments | cow_code | gnwo | tcc1 | tcc2 | tcc3 | tcc4 | tcc5 | tcc6 | tcc7 | tcc8 | tcc9 | tcc10 | tcc11 | tcc12 | tcc13 | tcc14 | tcc15 | tcc16 | tcc17 | adm1.id | adm1.name | prioid |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Map no. 4249 Rev. 08 | UNMIS | 2007 | 8 | Bentiu | 0 | Sudan | 9.233333 | 29.83333 | NA | GNS has two locations pointing to basically the same place. I took the coords for “seat of first-order admin division”, rahter than “populated place”, both are in line with GE. Also, today’s south sudan | NA | 0 | 1 | 0 | 0 | NA | 150 | NA | NA | 1 | 150 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | NA | NA | NA | 0 | 0 | NA | 1 | 1 | India | 150 | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | 0 | 1 | 0 | 0 | 0 | FALSE | 0 | NA | 625 | 625 | 750 | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | 622 | Unity | 142980 |
Map no. 4249 Rev. 08 | UNMIS | 2007 | 8 | Bor | 0 | Sudan | 6.205931 | 31.55633 | NA | GNS has two locations, the “seat of first-order admin division” pointing to location of Google Earth by same name, as well as corresponding to source map, hence that one coded. Also, today’s south sudan | NA | 0 | 0 | 0 | 0 | NA | 0 | NA | NA | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | NA | NA | NA | 0 | 0 | NA | 0 | 0 | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | 0 | 1 | 0 | 0 | 0 | FALSE | 0 | NA | 625 | 625 | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | 621 | Jungoli | 138664 |
Map no. 4249 Rev. 08 | UNMIS | 2007 | 8 | Dilling | 0 | Sudan | 12.050000 | 29.65000 | NA | NA | NA | 0 | 0 | 0 | 0 | NA | 0 | NA | NA | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | NA | NA | NA | 0 | 0 | NA | 0 | 0 | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | 0 | 1 | 0 | 0 | 0 | FALSE | 0 | NA | 625 | 625 | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | 720 | South Kordufan | 147300 |
Map no. 4249 Rev. 08 | UNMIS | 2007 | 8 | Ed Damazin | 0 | Sudan | 11.789100 | 34.35920 | NA | NA | NA | 1 | 4 | 0 | 0 | NA | 1250 | NA | NA | 1 | 650 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | NA | NA | NA | 0 | 0 | NA | 1, 2, 4, 11, 14 | 1 | Pakistan | 1250 | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | 0 | 1 | 0 | 2 | 0 | FALSE | 0 | NA | 625 | 625 | 770 | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | 287 | Blue Nile | 146589 |
Map no. 4249 Rev. 08 | UNMIS | 2007 | 8 | El Obeid | 0 | Sudan | 13.183333 | 30.21667 | NA | NA | NA | 0 | 1 | 0 | 0 | NA | 150 | NA | NA | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | NA | NA | NA | 1 | 0 | NA | 99 | 0 | unknown | 150 | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | 0 | 0 | NA | 0 | 0 | FALSE | 0 | “other” troop type refers to LOG company, unknown TCC | 625 | 625 | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | 721 | North Kordufan | 148741 |
Map no. 4249 Rev. 08 | UNMIS | 2007 | 8 | Juba | 0 | Sudan | 4.845972 | 31.60120 | NA | today’s south sudan | NA | 1 | 7 | 0 | 0 | NA | 1700 | NA | NA | 1 | 650 | 0 | 0 | 1 | 150 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 1 | 1 | 0 | NA | NA | NA | 1 | 0 | NA | 1, 2, 4, 11, 13, 14, 15, 99 | 3 | Bangladesh | 1400 | India | 150 | Russia | 150 | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | 0 | 1 | 0 | 2 | 0 | TRUE | 0 | Reserve = FRB 1 company (TCC India), troop type other refers 1 AMET company (Bangladesh), | 625 | 625 | 771 | 750 | 365 | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | 619 | Central Equatoria | 136504 |
Map no. 4249 Rev. 08 | UNMIS | 2007 | 8 | Julud | 0 | Sudan | 11.974816 | 29.34032 | NA | GNS/Google Earth not found, estimated on GE based on source map. | NA | 0 | 0 | 0 | 0 | NA | 0 | NA | NA | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | NA | NA | NA | 0 | 0 | NA | 0 | 0 | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | 0 | 1 | 0 | 0 | 0 | FALSE | 0 | NA | 625 | 625 | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | 720 | South Kordufan | 146579 |
Map no. 4249 Rev. 08 | UNMIS | 2007 | 8 | Kadugli | 0 | Sudan | 11.016667 | 29.71667 | NA | NA | NA | 1 | 5 | 0 | 0 | NA | 1400 | NA | NA | 1 | 150 | 0 | 0 | 1 | 650 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 1 | 0 | 1 | 0 | NA | NA | NA | 0 | 0 | NA | 1, 2, 8, 11, 14, 15 | 2 | Egypt | 600 | India | 800 | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | 0 | 1 | 0 | 2 | 0 | FALSE | 0 | Reserve = FRB 1 batallion (India) | 625 | 625 | 651 | 750 | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | 720 | South Kordufan | 145860 |
Map no. 4249 Rev. 08 | UNMIS | 2007 | 8 | Kauda | 0 | Sudan | 11.100000 | 30.51667 | NA | NA | NA | 0 | 0 | 0 | 0 | NA | 0 | NA | NA | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | NA | NA | NA | 0 | 0 | NA | 0 | 0 | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | 0 | 1 | 0 | 0 | 0 | FALSE | 0 | NA | 625 | 625 | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | 720 | South Kordufan | 145862 |
Map no. 4249 Rev. 08 | UNMIS | 2007 | 8 | Khartoum | 0 | Sudan | 15.588056 | 32.53417 | NA | NA | NA | 1 | 0 | 0 | 0 | NA | 650 | NA | NA | 1 | 650 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | NA | NA | NA | 0 | 0 | NA | 1 | 1 | Rwanda | 650 | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | 1 | 1 | 0 | 3 | 0 | FALSE | 0 | NA | 625 | 625 | 517 | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | 712 | Khartoum | 152346 |
We first need to filter the Geo-PKO data to include only observations for the year 2019, the latest year in version 2.0. We also remove countries outside Africa, as the ViEWS dataset only covers this continent.
Note: 2020 data is not currently available, but will be in early 2021. The dataset used for this visualisation will then be updated.
# filtering for troop deployments for the year 2019 in Africa
geopko2 <- geopko %>%
filter(year=="2019") %>%
# subsetting columns so we have a smaller data frame to work with
select(mission, prioid, no.troops, country, location, latitude, longitude) %>%
dplyr::mutate_at(vars(longitude, latitude, no.troops), as.numeric) %>%
# filtering out missions that did not take place in Africa
filter(!(country %in% c("Kosovo", "Lebanon", "Haiti", "Syria", "Cyprus")))
# for a list of host countries in the Geo-PKO dataset, you can run the following:
# geopko %>% distinct(country)
We now need to calculate the average number of troops deployed over that time period. In the visualisation, we’ll use coordinates to map every single deployment locations, so the average is calculated by location. In the next step, we use this number to calculate the average number of deployed troops for each PRIO-grid square. As a PRIO-grid is quite large, one grid square may have been home to multiple locations. We won’t visualise this bit of data here, but this is useful for understanding how to synthesize datasets with different units of analysis.
# calculating an average number of troops per location
geopko2 <- geopko2 %>%
group_by_at(vars(-no.troops)) %>%
dplyr::summarise(no.troops.yearly.avr = round(mean(no.troops, na.rm=TRUE))) %>%
ungroup() %>%
# summing the troop count for each prio grid
group_by(prioid) %>%
dplyr::mutate(no.troops.prio = sum(no.troops.yearly.avr, na.rm=TRUE)) %>%
ungroup()
The predictor database begins with July 2020 and forecasts the risk of conflict over the next 36 months ahead. Here’s a preview of the data within it, showing state-based (sb
), non-state (ns
) and one-sided violence (os
) forecasts. The variable month_id
codes months differently to the Geo-PKO dataset, with every month assigned a different numeric value.
kable(predictors[90545:90550,]) %>% kable_styling() %>%
scroll_box(width = "100%", height = "400px")
month_id | pg_id | average_allwthematic_sb | average_allwthematic_ns | average_allwthematic_os | |
---|---|---|---|---|---|
90545 | 494 | 141560 | 0.0056672 | 0.0040548 | 0.0049985 |
90546 | 494 | 141561 | 0.0054137 | 0.0032145 | 0.0038274 |
90547 | 494 | 141562 | 0.0115811 | 0.0073864 | 0.0045633 |
90548 | 494 | 141563 | 0.0093885 | 0.0043294 | 0.0027875 |
90549 | 494 | 141564 | 0.0085510 | 0.0184678 | 0.0043437 |
90550 | 494 | 141565 | 0.0098269 | 0.0046215 | 0.0037409 |
You’ll see both the Geo-PKO and ViEWS datasets include the PRIO-grid identification variable (pg_id
or prioid
), which corresponds to a specific grid square on the map. This is what we’ll use to eventually merge the datasets. For now, we subset the ViEWS predictions to include only the month of July 2020, which gives us a lagged time period of six months between the Geo-PKO observations and ViEWS predictions.
predictors2 <- predictors %>%
filter(month_id==486)
Finally, we merge the two datasets.
priogriddf <- left_join(
predictors2, geopko2,
by = c("pg_id"="prioid"),
name="pg_id")
Like we mentioned before, the PRIO-grid unit involves dividing the entire world into roughly 100km x 100km squares. That means that if we want to map it, we’ll be working with large files, so keep that in mind when you’re reading in the shapefile.
OGR data source with driver: GeoJSON
Source: "C:\Users\Nguyen Ha\Documents\DPCR\GeoPKO\Pages\GeoPKO\data\ViEWS\priogrid.geojson", layer: "priogrid"
with 64818 features
It has 1 fields
The shapefile contains both geospatial polygon data and numerical data that corresponds to the ViEWS dataset; specifically, a PRIO-grid ID and a country ID. To work with the data within this shapefile, we need to fortify it. This converts it into a dataframe. We also convert the IDs to rownames to make it easier to work with. And, finally, we merge it with pgnewdf2
, which we created earlier.
# fortify
shapefile@data$id <- rownames(shapefile@data)
shapefile.df <- fortify(shapefile, region = "id")
# merge data
shapefile.df <- merge(shapefile, priogriddf, by.x = "pg_id", by.y = "pg_id", all.x=F, all.y=T, duplicateGeoms=TRUE)
Now shapefile.df
has the new attributes, including variables from both Geo-PKO and ViEWS. id
is a variable that ties the ‘polygon’, or a single square on the grid, to its location on the map. As many PRIO-grid squares will have a conflict forecast index but no troop deployments, many data points under Geo-PKO variables will show NA.
kable(shapefile.df@data[5386:5500,]) %>% kable_styling() %>%
scroll_box(width = "100%", height = "400px")
pg_id | id | month_id | average_allwthematic_sb | average_allwthematic_ns | average_allwthematic_os | mission | country | location | latitude | longitude | no.troops.yearly.avr | no.troops.prio | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
5386 | 142960 | 16815 | 486 | 0.0038824 | 0.0022568 | 0.0037296 | NA | NA | NA | NA | NA | NA | NA |
5387 | 142961 | 16816 | 486 | 0.0041070 | 0.0017938 | 0.0021648 | NA | NA | NA | NA | NA | NA | NA |
5388 | 142962 | 16817 | 486 | 0.0026617 | 0.0022553 | 0.0032941 | NA | NA | NA | NA | NA | NA | NA |
5389 | 142963 | 16818 | 486 | 0.0022654 | 0.0019824 | 0.0028631 | NA | NA | NA | NA | NA | NA | NA |
5390 | 142964 | 16819 | 486 | 0.0027963 | 0.0022319 | 0.0036279 | NA | NA | NA | NA | NA | NA | NA |
5391 | 142965 | 16820 | 486 | 0.0026532 | 0.0020810 | 0.0031885 | NA | NA | NA | NA | NA | NA | NA |
5392 | 142966 | 16821 | 486 | 0.0026570 | 0.0019803 | 0.0040816 | NA | NA | NA | NA | NA | NA | NA |
5393 | 142967 | 16822 | 486 | 0.0030261 | 0.0032091 | 0.0036799 | NA | NA | NA | NA | NA | NA | NA |
5394 | 142968 | 16823 | 486 | 0.0048318 | 0.0052461 | 0.0050416 | NA | NA | NA | NA | NA | NA | NA |
5395 | 142969 | 16824 | 486 | 0.0244170 | 0.0055964 | 0.0072135 | NA | NA | NA | NA | NA | NA | NA |
5396 | 142970 | 16825 | 486 | 0.0055342 | 0.0021692 | 0.0030499 | NA | NA | NA | NA | NA | NA | NA |
5397 | 142971 | 16826 | 486 | 0.0032251 | 0.0020708 | 0.0021431 | NA | NA | NA | NA | NA | NA | NA |
5398 | 142972 | 16827 | 486 | 0.0034121 | 0.0021737 | 0.0023336 | NA | NA | NA | NA | NA | NA | NA |
5399 | 142973 | 16828 | 486 | 0.0043921 | 0.0030074 | 0.0027574 | NA | NA | NA | NA | NA | NA | NA |
5400 | 142974 | 16829 | 486 | 0.0054323 | 0.0054343 | 0.0032919 | UNISFA | Sudan | Gok-machar | 9.215412 | 26.85991 | 0 | 0 |
5401 | 142975 | 16830 | 486 | 0.0065361 | 0.0037252 | 0.0032160 | NA | NA | NA | NA | NA | NA | NA |
5402 | 142976 | 16831 | 486 | 0.0169208 | 0.0062564 | 0.0049979 | NA | NA | NA | NA | NA | NA | NA |
5403 | 142977 | 16832 | 486 | 0.0062144 | 0.0076972 | 0.0046881 | UNISFA | Sudan | Athony | 9.470559 | 28.46404 | 335 | 335 |
5404 | 142978 | 16833 | 486 | 0.0055708 | 0.0509225 | 0.0055099 | UNISFA | Sudan | Agok | 9.357486 | 28.58258 | 128 | 278 |
5405 | 142978 | 16833 | 486 | 0.0055708 | 0.0509225 | 0.0055099 | UNISFA | Sudan | Marial Achak | 9.479328 | 28.62492 | 150 | 278 |
5406 | 142979 | 16834 | 486 | 0.0102152 | 0.0405263 | 0.0077651 | NA | NA | NA | NA | NA | NA | NA |
5407 | 142980 | 16835 | 486 | 0.0142708 | 0.0064349 | 0.0100021 | UNMISS | South Sudan | Bentiu | 9.259905 | 29.80011 | 1493 | 1493 |
5408 | 142981 | 16836 | 486 | 0.0053903 | 0.0024632 | 0.0031937 | NA | NA | NA | NA | NA | NA | NA |
5409 | 142982 | 16837 | 486 | 0.0061301 | 0.0039779 | 0.0042585 | NA | NA | NA | NA | NA | NA | NA |
5410 | 142983 | 16838 | 486 | 0.0064783 | 0.0031868 | 0.0044326 | NA | NA | NA | NA | NA | NA | NA |
5411 | 142984 | 16839 | 486 | 0.0098993 | 0.0049793 | 0.0050087 | NA | NA | NA | NA | NA | NA | NA |
5412 | 142985 | 16840 | 486 | 0.0060069 | 0.0032141 | 0.0038324 | NA | NA | NA | NA | NA | NA | NA |
5413 | 142986 | 16841 | 486 | 0.0052141 | 0.0032155 | 0.0027096 | NA | NA | NA | NA | NA | NA | NA |
5414 | 142987 | 16842 | 486 | 0.0081636 | 0.0034759 | 0.0050795 | NA | NA | NA | NA | NA | NA | NA |
5415 | 142988 | 16843 | 486 | 0.0043634 | 0.0028049 | 0.0024548 | NA | NA | NA | NA | NA | NA | NA |
5416 | 142989 | 16844 | 486 | 0.0102931 | 0.0040764 | 0.0054326 | NA | NA | NA | NA | NA | NA | NA |
5417 | 142990 | 16845 | 486 | 0.0091394 | 0.0132143 | 0.0060761 | NA | NA | NA | NA | NA | NA | NA |
5418 | 142991 | 16846 | 486 | 0.0091114 | 0.0047432 | 0.0070673 | NA | NA | NA | NA | NA | NA | NA |
5419 | 142992 | 16847 | 486 | 0.0155308 | 0.0070456 | 0.0343647 | NA | NA | NA | NA | NA | NA | NA |
5420 | 142993 | 16848 | 486 | 0.0069197 | 0.0079125 | 0.0045316 | NA | NA | NA | NA | NA | NA | NA |
5421 | 142994 | 16849 | 486 | 0.0329898 | 0.0055623 | 0.0133976 | NA | NA | NA | NA | NA | NA | NA |
5422 | 142995 | 16850 | 486 | 0.0061751 | 0.0037489 | 0.0051516 | NA | NA | NA | NA | NA | NA | NA |
5423 | 142996 | 16851 | 486 | 0.0056568 | 0.0037440 | 0.0078758 | NA | NA | NA | NA | NA | NA | NA |
5424 | 142997 | 16852 | 486 | 0.0089381 | 0.0047676 | 0.0163093 | NA | NA | NA | NA | NA | NA | NA |
5425 | 142998 | 16853 | 486 | 0.0314606 | 0.0154105 | 0.0400417 | NA | NA | NA | NA | NA | NA | NA |
5426 | 142999 | 16854 | 486 | 0.0065077 | 0.0037026 | 0.0063653 | NA | NA | NA | NA | NA | NA | NA |
5427 | 143000 | 16855 | 486 | 0.0058690 | 0.0040956 | 0.0050626 | NA | NA | NA | NA | NA | NA | NA |
5428 | 143001 | 16856 | 486 | 0.0091558 | 0.0058094 | 0.0226096 | NA | NA | NA | NA | NA | NA | NA |
5429 | 143002 | 16857 | 486 | 0.0113627 | 0.0075678 | 0.0108579 | NA | NA | NA | NA | NA | NA | NA |
5430 | 143003 | 16858 | 486 | 0.0124609 | 0.0063454 | 0.0105985 | NA | NA | NA | NA | NA | NA | NA |
5431 | 143004 | 16859 | 486 | 0.0123421 | 0.0058527 | 0.0121990 | NA | NA | NA | NA | NA | NA | NA |
5432 | 143005 | 16860 | 486 | 0.0152787 | 0.0292900 | 0.0283692 | NA | NA | NA | NA | NA | NA | NA |
5433 | 143006 | 16861 | 486 | 0.0128581 | 0.0127575 | 0.0108854 | NA | NA | NA | NA | NA | NA | NA |
5434 | 143007 | 16862 | 486 | 0.0089875 | 0.0050298 | 0.0085515 | NA | NA | NA | NA | NA | NA | NA |
5435 | 143008 | 16863 | 486 | 0.0089865 | 0.0062909 | 0.0060385 | NA | NA | NA | NA | NA | NA | NA |
5436 | 143009 | 16864 | 486 | 0.0087704 | 0.0048946 | 0.0044014 | NA | NA | NA | NA | NA | NA | NA |
5437 | 143010 | 16865 | 486 | 0.0084145 | 0.0037783 | 0.0044391 | NA | NA | NA | NA | NA | NA | NA |
5438 | 143011 | 16866 | 486 | 0.0079217 | 0.0031273 | 0.0032630 | NA | NA | NA | NA | NA | NA | NA |
5439 | 143012 | 16867 | 486 | 0.0074002 | 0.0031132 | 0.0027221 | NA | NA | NA | NA | NA | NA | NA |
5440 | 143013 | 16868 | 486 | 0.0075829 | 0.0031822 | 0.0029905 | NA | NA | NA | NA | NA | NA | NA |
5441 | 143014 | 16869 | 486 | 0.0081350 | 0.0048502 | 0.0027781 | NA | NA | NA | NA | NA | NA | NA |
5442 | 143015 | 16870 | 486 | 0.0137394 | 0.0055197 | 0.0037260 | NA | NA | NA | NA | NA | NA | NA |
5443 | 143016 | 16871 | 486 | 0.0104873 | 0.0053263 | 0.0080376 | NA | NA | NA | NA | NA | NA | NA |
5444 | 143017 | 16872 | 486 | 0.0071454 | 0.0035923 | 0.0034135 | NA | NA | NA | NA | NA | NA | NA |
5445 | 143018 | 16873 | 486 | 0.0074592 | 0.0099381 | 0.0036531 | NA | NA | NA | NA | NA | NA | NA |
5446 | 143019 | 16874 | 486 | 0.0071459 | 0.0037201 | 0.0024416 | NA | NA | NA | NA | NA | NA | NA |
5447 | 143020 | 16875 | 486 | 0.0072631 | 0.0036979 | 0.0025004 | NA | NA | NA | NA | NA | NA | NA |
5448 | 143021 | 16876 | 486 | 0.0070133 | 0.0035395 | 0.0020214 | NA | NA | NA | NA | NA | NA | NA |
5449 | 143022 | 16877 | 486 | 0.0067475 | 0.0024173 | 0.0021152 | NA | NA | NA | NA | NA | NA | NA |
5450 | 143612 | 16951 | 486 | 0.0029173 | 0.0015203 | 0.0024311 | NA | NA | NA | NA | NA | NA | NA |
5451 | 143613 | 16952 | 486 | 0.0084545 | 0.0041365 | 0.0188877 | NA | NA | NA | NA | NA | NA | NA |
5452 | 143614 | 16953 | 486 | 0.0055442 | 0.0035424 | 0.0071654 | NA | NA | NA | NA | NA | NA | NA |
5453 | 143615 | 16954 | 486 | 0.0032308 | 0.0017484 | 0.0031580 | NA | NA | NA | NA | NA | NA | NA |
5454 | 143616 | 16955 | 486 | 0.0042212 | 0.0017180 | 0.0040975 | NA | NA | NA | NA | NA | NA | NA |
5455 | 143617 | 16956 | 486 | 0.0043621 | 0.0015122 | 0.0044656 | NA | NA | NA | NA | NA | NA | NA |
5456 | 143618 | 16957 | 486 | 0.0042203 | 0.0018184 | 0.0044225 | NA | NA | NA | NA | NA | NA | NA |
5457 | 143619 | 16958 | 486 | 0.0040969 | 0.0018089 | 0.0033085 | NA | NA | NA | NA | NA | NA | NA |
5458 | 143620 | 16959 | 486 | 0.0031173 | 0.0020361 | 0.0032273 | NA | NA | NA | NA | NA | NA | NA |
5459 | 143621 | 16960 | 486 | 0.0032975 | 0.0019192 | 0.0036548 | NA | NA | NA | NA | NA | NA | NA |
5460 | 143622 | 16961 | 486 | 0.0027427 | 0.0018215 | 0.0028786 | NA | NA | NA | NA | NA | NA | NA |
5461 | 143623 | 16962 | 486 | 0.0032921 | 0.0015830 | 0.0027836 | NA | NA | NA | NA | NA | NA | NA |
5462 | 143624 | 16963 | 486 | 0.0033064 | 0.0018881 | 0.0032171 | NA | NA | NA | NA | NA | NA | NA |
5463 | 143625 | 16964 | 486 | 0.0041152 | 0.0025124 | 0.0039843 | NA | NA | NA | NA | NA | NA | NA |
5464 | 143626 | 16965 | 486 | 0.0026959 | 0.0016769 | 0.0022480 | NA | NA | NA | NA | NA | NA | NA |
5465 | 143627 | 16966 | 486 | 0.0029141 | 0.0018863 | 0.0025911 | NA | NA | NA | NA | NA | NA | NA |
5466 | 143628 | 16967 | 486 | 0.0032218 | 0.0022249 | 0.0027566 | NA | NA | NA | NA | NA | NA | NA |
5467 | 143629 | 16968 | 486 | 0.0035042 | 0.0022265 | 0.0032172 | NA | NA | NA | NA | NA | NA | NA |
5468 | 143630 | 16969 | 486 | 0.0075799 | 0.0033944 | 0.0050007 | NA | NA | NA | NA | NA | NA | NA |
5469 | 143631 | 16970 | 486 | 0.0063663 | 0.0020426 | 0.0031098 | NA | NA | NA | NA | NA | NA | NA |
5470 | 143632 | 16971 | 486 | 0.0113675 | 0.0027509 | 0.0073838 | NA | NA | NA | NA | NA | NA | NA |
5471 | 143633 | 16972 | 486 | 0.0032053 | 0.0019689 | 0.0023615 | NA | NA | NA | NA | NA | NA | NA |
5472 | 143634 | 16973 | 486 | 0.0032129 | 0.0024418 | 0.0030780 | NA | NA | NA | NA | NA | NA | NA |
5473 | 143635 | 16974 | 486 | 0.0052846 | 0.0031546 | 0.0046095 | NA | NA | NA | NA | NA | NA | NA |
5474 | 143636 | 16975 | 486 | 0.0035425 | 0.0019640 | 0.0025275 | NA | NA | NA | NA | NA | NA | NA |
5475 | 143637 | 16976 | 486 | 0.0025714 | 0.0020597 | 0.0021644 | NA | NA | NA | NA | NA | NA | NA |
5476 | 143638 | 16977 | 486 | 0.0030249 | 0.0024913 | 0.0026558 | NA | NA | NA | NA | NA | NA | NA |
5477 | 143639 | 16978 | 486 | 0.0034638 | 0.0027427 | 0.0032370 | NA | NA | NA | NA | NA | NA | NA |
5478 | 143640 | 16979 | 486 | 0.0032344 | 0.0029057 | 0.0029564 | NA | NA | NA | NA | NA | NA | NA |
5479 | 143641 | 16980 | 486 | 0.0050388 | 0.0036084 | 0.0048726 | NA | NA | NA | NA | NA | NA | NA |
5480 | 143642 | 16981 | 486 | 0.0034228 | 0.0021162 | 0.0030131 | NA | NA | NA | NA | NA | NA | NA |
5481 | 143643 | 16982 | 486 | 0.0061890 | 0.0038615 | 0.0074817 | NA | NA | NA | NA | NA | NA | NA |
5482 | 143644 | 16983 | 486 | 0.0039599 | 0.0024352 | 0.0046044 | NA | NA | NA | NA | NA | NA | NA |
5483 | 143645 | 16984 | 486 | 0.0027797 | 0.0022436 | 0.0025579 | NA | NA | NA | NA | NA | NA | NA |
5484 | 143646 | 16985 | 486 | 0.0032871 | 0.0017466 | 0.0024051 | NA | NA | NA | NA | NA | NA | NA |
5485 | 143647 | 16986 | 486 | 0.0035130 | 0.0021294 | 0.0060667 | NA | NA | NA | NA | NA | NA | NA |
5486 | 143648 | 16987 | 486 | 0.0059859 | 0.0069254 | 0.0062558 | NA | NA | NA | NA | NA | NA | NA |
5487 | 143649 | 16988 | 486 | 0.0064681 | 0.0092315 | 0.0069150 | NA | NA | NA | NA | NA | NA | NA |
5488 | 143650 | 16989 | 486 | 0.0076255 | 0.0098509 | 0.0039985 | NA | NA | NA | NA | NA | NA | NA |
5489 | 143651 | 16990 | 486 | 0.0282848 | 0.0117731 | 0.0094136 | NA | NA | NA | NA | NA | NA | NA |
5490 | 143652 | 16991 | 486 | 0.0141636 | 0.0116765 | 0.0230129 | NA | NA | NA | NA | NA | NA | NA |
5491 | 143653 | 16992 | 486 | 0.0221102 | 0.0422745 | 0.0419147 | NA | NA | NA | NA | NA | NA | NA |
5492 | 143654 | 16993 | 486 | 0.0532576 | 0.0469015 | 0.0259562 | NA | NA | NA | NA | NA | NA | NA |
5493 | 143655 | 16994 | 486 | 0.0184486 | 0.0157384 | 0.0222044 | NA | NA | NA | NA | NA | NA | NA |
5494 | 143656 | 16995 | 486 | 0.0076151 | 0.0164903 | 0.0078290 | NA | NA | NA | NA | NA | NA | NA |
5495 | 143657 | 16996 | 486 | 0.0261824 | 0.1440699 | 0.0173727 | NA | NA | NA | NA | NA | NA | NA |
5496 | 143658 | 16997 | 486 | 0.0323618 | 0.2729190 | 0.0609969 | NA | NA | NA | NA | NA | NA | NA |
5497 | 143659 | 16998 | 486 | 0.0069876 | 0.0290492 | 0.0077272 | NA | NA | NA | NA | NA | NA | NA |
5498 | 143660 | 16999 | 486 | 0.0080614 | 0.0224487 | 0.0078844 | NA | NA | NA | NA | NA | NA | NA |
5499 | 143661 | 17000 | 486 | 0.0059992 | 0.0168699 | 0.0052389 | NA | NA | NA | NA | NA | NA | NA |
5500 | 143662 | 17001 | 486 | 0.0080721 | 0.0177159 | 0.0137558 | NA | NA | NA | NA | NA | NA | NA |
To map the data, we’re going to use the leaflet
package (and a bunch of others to support it). The first thing we do is set up our colour palette and bins. We’re using the ‘viridis’ colour palette, designed for accessibility and continuous-scale representation. The other thing we include is a small segment of code that fixes spacing between any NA value in the legend, and the remainder of the legend, making it easier to see.
bins <- c(0, 10, 20, 50, 100, 200, 500, 1000, Inf)
pal <- colorNumeric("viridis", NULL)
#to fix spacing of NA in legend
css_fix <- "div.info.legend.leaflet-control br {clear: both;}" # CSS to correct spacing
html_fix <- htmltools::tags$style(type = "text/css", css_fix) # Convert CSS to HTML
Next, let’s map. We include three colour layers to shade squares according to their conflict forecast value. These layers can be toggled between state-based conflict, non-state conflict, and one-sided violence. Troop deployment numbers are included as labels, which you can see for each square on hover. Labels for specific deployment locations also show the name of the location and country, on hover over location markers.
Zoom in for more detail.
map <- leaflet(shapefile.df) %>%
addTiles() %>%
addPolygons(
color = "#444444", weight = 0.25, smoothFactor = 0.5,
opacity = 0.05, fillOpacity = 0.4,
fillColor = ~ pal(shapefile.df@data$average_allwthematic_sb),
group = "State-Based Conflict",
highlightOptions = highlightOptions(
color = "white", weight = 2,
bringToFront = FALSE
)
) %>%
addPolygons(
color = "#444444", weight = 0.25, smoothFactor = 0.5,
opacity = 0.05, fillOpacity = 0.4,
fillColor = ~ pal(shapefile.df@data$average_allwthematic_ns),
group = "Non-State Conflict",
highlightOptions = highlightOptions(
color = "white", weight = 2,
bringToFront = TRUE
)
) %>%
addPolygons(
color = "#444444", weight = 0.25, smoothFactor = 0.5,
opacity = 0.05, fillOpacity = 0.4,
fillColor = ~ pal(shapefile.df@data$average_allwthematic_os),
group = "One-Sided Violence",
highlightOptions = highlightOptions(
color = "white", weight = 2,
bringToFront = TRUE
)
) %>%
# these circle markers use geopko3 data to cover multiple locations per prioid
addCircleMarkers(data = geopko2,
lat = ~latitude, lng = ~longitude,
weight = 1, radius = 2, fillOpacity = 0.6, color = "darkblue",
group = "Deployment Locations",
label = paste0(
"<strong>Deployment Location: </strong>", geopko2$mission,
"<br/><strong>Number of Troops: </strong>", geopko2$no.troops.yearly.avr,
"<br/><strong>Location: </strong>", geopko2$location,", ", geopko2$country
)
%>%
lapply(htmltools::HTML)
) %>%
addLegend("bottomright",
pal = pal,
values = shapefile.df$average_allwthematic_sb,
title = "Conflict Forecast",
opacity = 1
) %>%
addLayersControl(
baseGroups = c("State-Based Conflict", "Non-State Conflict", "One-Sided Violence"),
overlayGroups = c("Deployment Locations"),
options = layersControlOptions(collapsed = FALSE)
) %>%
htmlwidgets::prependContent(html_fix) # legend NA fix
map
And here we have it: an interactive map to view the latest peacekeeping data and projected conflict risk over the following 36 months. You can zoom in to areas of higher conflict risk to see more detail, including deployment locations. Note that some marked locations still say 0 for troop count; this indicates a mission site where no troops are deployed, but support personnel such as UNPOL or UNMO are present.
We can also do the same but with a world terrain basemap to identify, at a basic level, potential geographic impacts such as the greater concentration of conflict risk in mountainous areas, and the general deployment of peacekeepers in non-mountainous areas.
# adding provider tiles - replaces addTiles()
map <- map %>% addProviderTiles("Esri.WorldTerrain")
map
Extensions of this visualisation can be even more useful, particularly with a time-slider that can help us identify how the risk of conflict changes given peacekeeping deployments (and vice versa). That would be a valuable be a project for the future.
Another useful dataset is from the Uppsala Conflict Data Programme, which offers insights into deaths from armed conflict. Looking at this data in conjunction with peacekeeping data can be useful to draw conclusions into peacekeeping given the severity of armed conflict, or lack thereof. We start by importing the “UCDP Georeferenced Event Dataset (GED) Global version 20.1”, of which a small excerpt of 2011 is shown in the table below.
UCDP <- read_csv("data/UCDP/ged201.csv")
kable(UCDP[9546:9550,]) %>% kable_styling() %>%
scroll_box(width = "100%", height = "200px")
year | longitude | latitude | where_coordinates | best | deaths_civilians |
---|---|---|---|---|---|
2019 | 68.23228 | 33.60806 | Dara Qayaq river | 2 | 0 |
2019 | 63.11753 | 31.91940 | Rakin village | 1 | 0 |
2019 | 65.87257 | 36.30936 | Khanaqa village | 7 | 0 |
2019 | 69.42800 | 37.41980 | Qara Tapa village | 17 | 0 |
2019 | 70.21723 | 33.46187 | Babrak Tana ruin | 6 | 6 |
For the Geo-PKO data we only use certain variables, and calculate the average troop number by year. The UCDP data has different variables you could use. In this example we took best
, which indicates “the best (most likely) estimate of total fatalities resulting from integer an event” and deaths_civilians
, which tells us how many of this best
variable were civilian deaths.
# Preparing the Geo-PKO dataset
GeoPKO_dataUCDP <- geopko %>%
select(mission, year, location, latitude, longitude, no.troops) %>% # Select only the variables you need
mutate_at(vars(latitude, longitude, no.troops), as.numeric) %>%
group_by(mission, year, location) %>%
mutate(ave.no.troops = as.integer(mean(no.troops, na.rm = TRUE))) %>% # Sum the troop numbers by year through using a combination of group_by & mutate
select(-no.troops) %>% # Deselect the previous troop number variable
distinct() %>% # Delete any duplicate rows
drop_na(ave.no.troops) %>% # Remove NAs from the average troop count
filter(ave.no.troops > 0) # Exclude any troop numbers under the value of 0
# Preparing the UCDP dataset
UCDP_dataframe <- UCDP %>%
select(year, longitude, latitude, where_coordinates, best, deaths_civilians) %>%
drop_na(latitude, longitude) %>%
group_by(year, where_coordinates) %>%
mutate(best = as.integer(mean(best, na.rm = TRUE))) %>% # Take the mean of the "best" variable
mutate(deaths_civilians = as.integer(mean(deaths_civilians, na.rm = TRUE))) %>% # Take the mean of the "deaths_civilians" variable
filter(best > 0 & year >= 1995) %>% # Filter that data so that it only keeps rows for the years after 1995.
distinct()
You can either set all the colours by hand, as seen in pal3
, or use the “viridis” package to create a colour scale for you, as shown in pal2
. For the UCDP data we used shades of red. The Geo-PKO data is mapped with viridis, which includes blue, green, and yellow.
pal2 <- colorBin((viridis::viridis(10)), GeoPKO_dataUCDP$ave.no.troops, bins = c(1, 50, 100, 500, 1000, 2000, 4000, 8000))
pal3 <- colorBin(c("#700524", "#8d072e", "#981f42", "#ed4d3a", "#af516c", "#d19bab", "#dcb4c0"),
UCDP_dataframe$best,
bins = c(1, 50, 100, 500, 1000, 2000, 4000, 10000, Inf)
)
Just as we used leaflet for the ViEWS map, we do the same here. Note that in this case we did not merge the two datasets into one dataframe. When hovering over the circles, more information will be provided on either the UN peacekeeping deployment or on the UCDP conflict-related deaths. It is possible to use the PRIO-grid ID instead, and both datasets include this variable.
leaflet() %>%
addTiles(options = providerTileOptions(noWrap = TRUE)) %>%
addMeasure(position = "bottomleft", primaryLengthUnit = "kilometers") %>% # Adds a widget that can measure distances between two places to the map
clearMarkers() %>%
clearShapes() %>%
addLegend("topright",
pal = pal3,
values = UCDP$best,
title = "Fatalities",
opacity = 1
) %>%
addLegend("topright",
pal = pal2,
values = GeoPKO_dataUCDP$ave.no.troops,
title = "Peacekeepers",
opacity = 1
) %>%
addLayersControl(
baseGroups = c("2019", "2018", "2015", "2010", "2005", "2000", "1995"),
options = layersControlOptions(collapsed = FALSE), position = "topleft"
) %>%
addCircleMarkers(
data = (GeoPKO2019 <- GeoPKO_dataUCDP %>% filter(year == 2019)),
color = ~ pal2(ave.no.troops), radius = ~ (ave.no.troops)^(1 / 3),
opacity = 0.15, fillOpacity = 0.5,
lng = ~longitude, lat = ~latitude, group = "2019",
label = paste(
"<strong>UN Peacekeeping Site<br/>Mission:</strong>", GeoPKO2019$mission,
"<br/><strong>Location:</strong>", GeoPKO2019$location,
"<br/><strong>Troops Deployed:</strong>", GeoPKO2019$ave.no.troops
) %>%
lapply(htmltools::HTML)
) %>%
addCircleMarkers(
data = (UCDP2019 <- UCDP_dataframe %>% filter(year == 2019)),
lng = ~longitude, lat = ~latitude,
color = ~ pal3(best), radius = ~ (best)^(1 / 3),
opacity = 0.05, fillOpacity = 0.4,
group = "2019",
label = paste(
"<strong>UCDP Reported Fatalities<br/>Location:</strong>", UCDP2019$where_coordinates,
"<br/><strong>Total deaths:</strong>", UCDP2019$best,
"<br/><strong>Civilian deaths:</strong>", UCDP2019$deaths_civilians
) %>%
lapply(htmltools::HTML)
) %>%
addCircleMarkers(
data = (GeoPKO2018 <- GeoPKO_dataUCDP %>% filter(year == 2018)),
color = ~ pal2(ave.no.troops), radius = ~ (ave.no.troops)^(1 / 3),
opacity = 0.15, fillOpacity = 0.5,
lng = ~longitude, lat = ~latitude, group = "2018",
label = paste(
"<strong>UN Peacekeeping Site<br/>Mission:</strong>", GeoPKO2018$mission,
"<br/><strong>Location:</strong>", GeoPKO2018$location,
"<br/><strong>Troops Deployed:</strong>", GeoPKO2018$ave.no.troops
) %>%
lapply(htmltools::HTML)
) %>%
addCircleMarkers(
data = (UCDP2018 <- UCDP_dataframe %>% filter(year == 2018)),
lng = ~longitude, lat = ~latitude,
color = ~ pal3(best), radius = ~ (best)^(1 / 3),
opacity = 0.05, fillOpacity = 0.4,
group = "2018",
label = paste(
"<strong>UCDP Reported Fatalities<br/>Location:</strong>", UCDP2018$where_coordinates,
"<br/><strong>Total deaths:</strong>", UCDP2018$best,
"<br/><strong>Civilian deaths:</strong>", UCDP2018$deaths_civilians
) %>% lapply(htmltools::HTML)
) %>%
addCircleMarkers(
data = (GeoPKO2015 <- GeoPKO_dataUCDP %>% filter(year == 2015)),
color = ~ pal2(ave.no.troops), radius = ~ (ave.no.troops)^(1 / 3),
opacity = 0.15, fillOpacity = 0.5,
lng = ~longitude, lat = ~latitude, group = "2015",
label = paste(
"<strong>UN Peacekeeping Site<br/>Mission:</strong>", GeoPKO2015$mission,
"<br/><strong>Location:</strong>", GeoPKO2015$location,
"<br/><strong>Troops Deployed:</strong>", GeoPKO2015$ave.no.troops
) %>%
lapply(htmltools::HTML)
) %>%
addCircleMarkers(
data = (UCDP2015 <- UCDP_dataframe %>% filter(year == 2015)),
lng = ~longitude, lat = ~latitude,
color = ~ pal3(best), radius = ~ (best)^(1 / 3),
opacity = 0.05, fillOpacity = 0.4,
group = "2015",
label = paste(
"<strong>UCDP Reported Fatalities<br/>Location:</strong>", UCDP2015$where_coordinates,
"<br/><strong>Total deaths:</strong>", UCDP2015$best,
"<br/><strong>Civilian deaths:</strong>", UCDP2015$deaths_civilians
) %>% lapply(htmltools::HTML)
) %>%
addCircleMarkers(
data = (GeoPKO2010 <- GeoPKO_dataUCDP %>% filter(year == 2010)),
color = ~ pal2(ave.no.troops), radius = ~ (ave.no.troops)^(1 / 3),
opacity = 0.15, fillOpacity = 0.5,
lng = ~longitude, lat = ~latitude, group = "2010",
label = paste(
"<strong>UN Peacekeeping Site<br/>Mission:</strong>", GeoPKO2010$mission,
"<br/><strong>Location:</strong>", GeoPKO2010$location,
"<br/><strong>Troops Deployed:</strong>", GeoPKO2010$ave.no.troops
) %>%
lapply(htmltools::HTML)
) %>%
addCircleMarkers(
data = (UCDP2010 <- UCDP_dataframe %>% filter(year == 2010)),
lng = ~longitude, lat = ~latitude,
color = ~ pal3(best), radius = ~ (best)^(1 / 3),
opacity = 0.05, fillOpacity = 0.4,
group = "2010",
label = paste(
"<strong>UCDP Reported Fatalities<br/>Location:</strong>", UCDP2010$where_coordinates,
"<br/><strong>Total deaths:</strong>", UCDP2010$best,
"<br/><strong>Civilian deaths:</strong>", UCDP2010$deaths_civilians
) %>% lapply(htmltools::HTML)
) %>%
addCircleMarkers(
data = (GeoPKO2005 <- GeoPKO_dataUCDP %>% filter(year == 2005)),
color = ~ pal2(ave.no.troops), radius = ~ (ave.no.troops)^(1 / 3),
opacity = 0.15, fillOpacity = 0.5,
lng = ~longitude, lat = ~latitude, group = "2005",
label = paste(
"<strong>UN Peacekeeping Site<br/>Mission:</strong>", GeoPKO2005$mission,
"<br/><strong>Location:</strong>", GeoPKO2005$location,
"<br/><strong>Troops Deployed:</strong>", GeoPKO2005$ave.no.troops
) %>%
lapply(htmltools::HTML)
) %>%
addCircleMarkers(
data = (UCDP2005 <- UCDP_dataframe %>% filter(year == 2005)),
lng = ~longitude, lat = ~latitude,
color = ~ pal3(best), radius = ~ (best)^(1 / 3),
opacity = 0.05, fillOpacity = 0.4,
group = "2005",
label = paste(
"<strong>UCDP Reported Fatalities<br/>Location:</strong>", UCDP2005$where_coordinates,
"<br/><strong>Total deaths:</strong>", UCDP2005$best,
"<br/><strong>Civilian deaths:</strong>", UCDP2005$deaths_civilians
) %>% lapply(htmltools::HTML)
) %>%
addCircleMarkers(
data = (GeoPKO2000 <- GeoPKO_dataUCDP %>% filter(year == 2000)), color = ~ pal2(ave.no.troops), radius = ~ (ave.no.troops)^(1 / 3),
opacity = 0.15, fillOpacity = 0.5,
lng = ~longitude, lat = ~latitude, group = "2000",
label = paste(
"<strong>UN Peacekeeping Site<br/>Mission:</strong>", GeoPKO2000$mission,
"<br/><strong>Location:</strong>", GeoPKO2000$location,
"<br/><strong>Troops Deployed:</strong>", GeoPKO2000$ave.no.troops
) %>%
lapply(htmltools::HTML)
) %>%
addCircleMarkers(
data = (UCDP2000 <- UCDP_dataframe %>% filter(year == 2000)),
lng = ~longitude, lat = ~latitude,
color = ~ pal3(best), radius = ~ (best)^(1 / 3),
opacity = 0.05, fillOpacity = 0.4,
group = "2000",
label = paste(
"<strong>UCDP Reported Fatalities<br/>Location:</strong>", UCDP2000$where_coordinates,
"<br/><strong>Total deaths:</strong>", UCDP2000$best,
"<br/><strong>Civilian deaths:</strong>", UCDP2000$deaths_civilians
) %>% lapply(htmltools::HTML)
) %>%
addCircleMarkers(
data = (GeoPKO1995 <- GeoPKO_dataUCDP %>% filter(year == 1995)), color = ~ pal2(ave.no.troops), radius = ~ (ave.no.troops)^(1 / 3),
lng = ~longitude, lat = ~latitude,
opacity = 0.15, fillOpacity = 0.5,
group = "1995",
label = paste(
"<strong>UN Peacekeeping Site<br/>Mission:</strong>", GeoPKO1995$mission,
"<br/><strong>Location:</strong>", GeoPKO1995$location,
"<br/><strong>Troops Deployed:</strong>", GeoPKO1995$ave.no.troops
) %>%
lapply(htmltools::HTML)
) %>%
addCircleMarkers(
data = (UCDP1995 <- UCDP_dataframe %>% filter(year == 1995)),
lng = ~longitude, lat = ~latitude, color = ~ pal3(best), radius = ~ (best)^(1 / 3),
opacity = 0.05, fillOpacity = 0.4,
group = "1995",
label = paste(
"<strong>UCDP Reported Fatalities<br/>Location:</strong>", UCDP1995$where_coordinates,
"<br/><strong>Total deaths:</strong>", UCDP1995$best,
"<br/><strong>Civilian deaths:</strong>", UCDP1995$deaths_civilians
) %>% lapply(htmltools::HTML)
)
# to save as HTML, you can use the following code:
# saveWidget(UCDP_Overview_Map, file="geopko&ucdp - geopko.html")
And here we have it again: an interactive map to view peacekeeping deployments, in a few selected years, and conflict-related deaths within that same year. Select different years to see how both the numbers and locations of both datasets have changed over time.
sessionInfo()
R version 4.0.2 (2020-06-22)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19041)
Matrix products: default
locale:
[1] LC_COLLATE=English_Sweden.1252 LC_CTYPE=English_Sweden.1252
[3] LC_MONETARY=English_Sweden.1252 LC_NUMERIC=C
[5] LC_TIME=English_Sweden.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] readr_1.3.1 kableExtra_1.1.0 leaflet.providers_1.9.0
[4] htmlwidgets_1.5.1 htmltools_0.5.0 rmapshaper_0.4.4
[7] RJSONIO_1.3-1.4 rjson_0.2.20 spdep_1.1-5
[10] spData_0.3.8 ggplot2_3.3.2 sf_0.9-5
[13] leaflet_2.0.3 rgdal_1.5-16 sp_1.4-2
[16] broom_0.7.0 geojsonio_0.9.2 tidyr_1.1.1
[19] dplyr_1.0.2 workflowr_1.6.2
loaded via a namespace (and not attached):
[1] nlme_3.1-148 fs_1.5.0 RColorBrewer_1.1-2 webshot_0.5.2
[5] httr_1.4.2 gmodels_2.18.1 rprojroot_1.3-2 tools_4.0.2
[9] backports_1.1.7 R6_2.4.1 KernSmooth_2.23-17 rgeos_0.5-3
[13] DBI_1.1.0 lazyeval_0.2.2 colorspace_1.4-1 raster_3.3-13
[17] withr_2.2.0 gridExtra_2.3 tidyselect_1.1.0 curl_4.3
[21] compiler_4.0.2 git2r_0.27.1 cli_2.0.2 rvest_0.3.6
[25] expm_0.999-5 xml2_1.3.2 scales_1.1.1 classInt_0.4-3
[29] stringr_1.4.0 digest_0.6.25 foreign_0.8-80 rmarkdown_2.3
[33] pkgconfig_2.0.3 highr_0.8 jsonvalidate_1.1.0 rlang_0.4.7
[37] rstudioapi_0.11 httpcode_0.3.0 farver_2.0.3 generics_0.0.2
[41] jsonlite_1.7.1 crosstalk_1.1.0.1 gtools_3.8.2 magrittr_1.5
[45] Matrix_1.2-18 fansi_0.4.1 Rcpp_1.0.5 munsell_0.5.0
[49] viridis_0.5.1 lifecycle_0.2.0 stringi_1.4.6 whisker_0.4
[53] yaml_2.2.1 MASS_7.3-52 jqr_1.1.0 grid_4.0.2
[57] maptools_1.0-2 gdata_2.18.0 promises_1.1.1 crayon_1.3.4
[61] deldir_0.2-3 lattice_0.20-41 splines_4.0.2 geojson_0.3.4
[65] hms_0.5.3 knitr_1.29 pillar_1.4.6 boot_1.3-25
[69] geojsonlint_0.4.0 codetools_0.2-16 LearnBayes_2.15.1 crul_1.0.0
[73] glue_1.4.1 evaluate_0.14 V8_3.2.0 vctrs_0.3.2
[77] httpuv_1.5.4 gtable_0.3.0 purrr_0.3.4 assertthat_0.2.1
[81] xfun_0.16 e1071_1.7-3 coda_0.19-4 later_1.1.0.1
[85] viridisLite_0.3.0 class_7.3-17 tibble_3.0.3 units_0.6-7
[89] ellipsis_0.3.1