-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathgeoboundaries_afrimapr.Rmd
76 lines (53 loc) · 2.6 KB
/
geoboundaries_afrimapr.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
64
65
66
67
68
69
70
71
72
---
title: "geoboundaries_afrimapr"
output: html_document
---
Experimenting with geoboundaries for Africa, partly in response to Dave Kennedy via twitter .
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
library(afriadmin) # partly just to get at country list, also potential to compare with other boundaries
library(mapview)
library(knitr) #for kable
library(dplyr)
library(ggplot2)
# install.packages("remotes")
remotes::install_gitlab("dickoa/rgeoboundaries")
library(rgeoboundaries)
```
```{r, eval=TRUE, warning=FALSE}
#' @param type character; defaults to HPSCU. One of HPSCU, HPSCGS, SSCGS, or SSCU.
#'
#' * HPSCU - High Precision Single Country Unstadardized. The premier geoBoundaries release,
#' * HPSCGS - High Precision Single Country Globally Standardized. A version of geoBoundaries
#' high precision data that has been clipped to the U.S. Department of State boundary file,
#' ensuring no contested boundaries or overlap in the dataset. This globally standardized
#' product may have gaps between countries. If you need a product with no gaps,
#' we recommend our simplified global product.
#' * SSCU - Simplified Single Country Unstandardized. A simplified version of every file
#' available for every country in the world. No standardization, maybe gaps.
#' * SSCGS - Simplified Single Country Globally Standardized. A version of geoBoundaries
#' simplified data that has been clipped to the U.S. Department of State boundary file,
#' ensuring no contested boundaries or overlap in the dataset.
#' This globally standardized product may have gaps between countries.
#test with a couple countries
sftest <- rgeoboundaries::geoboundaries(c("mali", "senegal"), adm_lvl = "adm0", type = "SSCGS")
#to get list of countries (from afriadmin)
data(afcountries)
sfafrica0 <- rgeoboundaries::geoboundaries(afcountries$name, adm_lvl = "adm0", type = "SSCGS")
# even this standardised one has some gaps for contested regions
# and doesn't have western sahara
mapview(sfafrica0)
# look at the simplified, unstandardized (SSCU) version
sfafrica_unstandard_0 <- rgeoboundaries::geoboundaries(afcountries$name, adm_lvl = "adm0", type = "SSCU")
#mapview(sfafrica_unstandard_0)
# each layer works in isolation but trying to compare them doesn't
# possibly a problem with my mapview version ?
#Error in if (!is.na(getProjection(lst[[i]]))) { :
# argument is of length zero
mapview::mapview(list(sfafrica0, sfafrica_unstandard_0),
fill=FALSE,
color=list('blue','red'),
col.region=list('blue','red'),
alpha=0.5,
lwd=1)
```