-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME.Rmd
124 lines (93 loc) · 3.23 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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
---
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%"
)
```
# geodk
<!-- badges: start -->
[](https://ropengov.r-universe.dev/geodk)
[](https://github.com/rOpenGov/geodk/actions/workflows/R-CMD-check.yaml)
[](https://app.codecov.io/gh/ropengov/geodk)
[](https://www.repostatus.org/#wip)
[](https://ropengov.org/)
<!-- badges: end -->
`{geodk}` provides access to Danish geospatial data.
## Installation
```{r check_cran, include=FALSE}
if (!require(available)) install.packages("available")
is_on_cran <- !available::available_on_cran("geodk")
```
```{r cran_instruct, echo=FALSE, results='asis', eval=is_on_cran}
cat("You can install `{geodk}` from CRAN with:")
```
```{r cran_code, eval=FALSE, include=is_on_cran}
install.packages("geodk")
```
```{r r_universe_instruct, echo=FALSE, results='asis'}
if (is_on_cran) {
cat("Or you can install the latest pre-release version of `{geodk}` from r-universe with:")
} else if (!is_on_cran) {
cat("You can install `{geodk}` from r-universe with:")
}
```
```{r r_universe, eval=FALSE}
install.packages(
"geodk",
repos = c(
ropengov = "https://ropengov.r-universe.dev",
getOption("repos")
)
)
```
You can install the latest development version of `{geodk}` from [GitHub](https://github.com/rOpenGov/geodk) with:
``` r
# install.packages("devtools")
devtools::install_github("rOpenGov/geodk")
```
## Functions
`{geodk}` provides three main sets of functions:
- Data retrieval
- Plotting
- Enrichment of statistical data from `{dkstat}`
### Data retrieval
The package contains a few functions for retrieving data.
```{r eval=FALSE}
regions()
municipalities()
parishes()
constituencies()
```
The geographic levels not included in their own functions can be accessed through `get_geo()`.
```{r eval=FALSE}
get_geo()
prefill_cache()
```
### Plotting
The plotting functions include `plot_denmark()` which easily plots a basic map of Denmark and returns it as a `{ggplot2}` object for you to edit. It also includes `plot_region()` and `plot_municipality()` which plots a subset of Denmark with focus on provided regions or municipalities.
```{r example}
library(geodk)
plot_denmark()
```
```{r}
region <- plot_regions(region = c("Region Nordjylland", "Region Midtjylland"))
```
```{r}
municipality <- plot_municipalities(municipality = c("Aarhus", "Favrskov", "Vejle"))
```
```{r}
library(patchwork)
region + municipality
```
### Enrichment of statistical data from `{dkstat}`
The function `geodk_enrich()` enables you to add appropriate geographic information to statistical descriptions from the `{dkstat}` package.
```{r eval=FALSE}
dkstat::dst_get_all_data("laby01") |>
geodk::geodk_enrich()
```