-
Notifications
You must be signed in to change notification settings - Fork 0
/
csipIII.Rmd
63 lines (53 loc) · 1.79 KB
/
csipIII.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
---
output:
html_document:
toc: true
toc_float: true
toc_collapsed: true
toc_depth: 3
number_sections: false
editor_options:
chunk_output_type: console
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
**Scenario III**
[ACLED](https://acleddata.com/) conflict data between 2017--2022 were used.
```{r k3, echo=FALSE, message=F, warning=F,comment=F}
library(terra)
library(tmap)
library(mapview)
root <- 'D:/OneDrive - CGIAR/Analysis/CSO/'
iso <- 'KEN'
conf <- geojsonio::geojson_sf(paste0(root,iso,'/clim_conflict_ips_overlays (ACCLED-2017-2022).geojson'))
conf <- conf[conf$conflict_clust_label=="High conflict" ,]
k <- unique(conf$intersect_conf_clim)
k <- rev(k)
#k <- c(k[1:4],k[9:12],k[5:8])
for(i in 1:length(k)){
conf$clust[conf$intersect_conf_clim==k[i]] <- i
}
#labs <- conf$intersect_conf_clim[!duplicated(conf$clust)]
labs <- gsub(" levels of|\\[|/.*", "", k)
conf$clust <- as.factor(conf$clust)
bdy1 <- geodata::gadm(country=iso, level=1, path=paste0(root,iso,'/'))
bdy1 <- sf::st_as_sf(bdy1)
bdy2 <- geodata::gadm(country=iso, level=2, path=paste0(root,iso,'/'))
bdy2 <- sf::st_as_sf(bdy2)
bdy3 <- geodata::gadm(country=iso, level=3, path=paste0(root,iso,'/'))
bdy3 <- sf::st_as_sf(bdy3)
conf$Ward <- conf$NAME_3
tmap_mode("view")
ken <- tm_shape(bdy1, name = 'County')+
tm_borders() +
#tm_shape(bdy2, name = 'Subcounty')+
#tm_borders() +
#tm_shape(bdy3, name = 'Ward')+
#tm_borders()+
tm_shape(conf, name = 'Conflict')+
tm_fill(col= "clust", palette="-YlOrRd", title = 'Climate-Conflict-Hotspots', labels=labs, popup.vars=c("Ward", "FATALITIES", "climvar_medn_prec", "livelihoods", "female_population", "male_population", "median_male_female_edu_diff"))+
tm_view(view.legend.position =c("left", "bottom"))+
tm_format("World")
ken
```