forked from wmgeolab/rgeoboundaries
-
Notifications
You must be signed in to change notification settings - Fork 0
/
README.Rmd
executable file
·83 lines (60 loc) · 2.92 KB
/
README.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
73
74
75
76
77
78
79
80
81
82
83
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%",
dev = "svg"
)
```
# rgeoboundaries <img src="man/figures/hex-rgeoboundaries.png" align="right" height="139" />
<!-- badges: start -->
[![GitLab CI Build Status](https://gitlab.com/dickoa/rgeoboundaries/badges/master/pipeline.svg)](https://gitlab.com/dickoa/rgeoboundaries/pipelines)
[![AppVeyor build status](https://ci.appveyor.com/api/projects/status/gitlab/dickoa/rgeoboundaries?branch=master&svg=true)](https://ci.appveyor.com/project/dickoa/rgeoboundaries)
[![Codecov Code Coverage](https://codecov.io/gl/dickoa/rgeoboundaries/branch/master/graph/badge.svg)](https://codecov.io/gl/dickoa/rgeoboundaries)
[![CRAN status](https://www.r-pkg.org/badges/version/rgeoboundaries)](https://cran.r-project.org/package=rgeoboundaries)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
`rgeoboundaries` is an R client for the [geoBoundaries API](https://www.geoboundaries.org/), providing country political administrative boundaries.
<!-- badges: end -->
## Installation
You can install the development version of rgeoboundaries using the `remotes` package:
``` {r, eval = FALSE}
# install.packages("remotes")
remotes::install_gitlab("dickoa/rgeoboundaries")
remotes::install_github("wmgeolab/rgeoboundaries")
```
## Access administrative boundaries using rgeoboundaries
This is a basic example which shows you how get Mali and Senegal boundaries and plot it
```{r plot, cache = TRUE}
library(rgeoboundaries)
library(sf)
mli_sen <- gb_adm0(c("mali", "senegal"), type = "sscgs")
plot(st_geometry(mli_sen))
```
We can also get the first administrative division of all countries in the world and use ISO3 code too
```{r plot_egy, cache = TRUE}
egy <- gb_adm1("EGY")
plot(st_geometry(egy),
col = rgb(red = 1, green = 0, blue = 0, alpha = 0.5),
axes = TRUE, graticule = TRUE)
```
In order to access the global administrative zones, you just need to skip the country argument (i.e set it to `NULL`) or specify `type = "CGAZ"`.
```{r plot_world, cache = TRUE}
world <- gb_adm1()
world_lambert <- st_transform(world, "+proj=laea +x_0=0 +y_0=0 +lon_0=0 +lat_0=0")
par(bty = "n")
plot(st_geometry(world_lambert),
col = "#E39d57",
graticule = TRUE, lwd = 0.3)
```
Finally, metadata for each country and administrative level are also available.
```{r, metadata}
knitr::kable(gb_metadata(c("mali", "senegal"), "adm1"))
```
## How to to cite
If you are using this package in your analysis, please cite the original `geoBoundaries` work:
> Runfola D, Anderson A, Baier H, Crittenden M, Dowker E, Fuhrig S, et al. (2020) geoBoundaries: A global database of political administrative boundaries. PLoS ONE 15(4): e0231866. https://doi.org/10.1371/journal.pone.0231866