An open API service indexing awesome lists of open source software.

https://github.com/ropengov/geodk

R package for danish geographic data
https://github.com/ropengov/geodk

denmark denmark-map geodk geospatial r r-lang

Last synced: 3 months ago
JSON representation

R package for danish geographic data

Awesome Lists containing this project

README

          

---
output: github_document
---

```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```

# geodk

[![geodk status badge](https://ropengov.r-universe.dev/badges/geodk)](https://ropengov.r-universe.dev/geodk)
[![R-CMD-check](https://github.com/rOpenGov/geodk/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/rOpenGov/geodk/actions/workflows/R-CMD-check.yaml)
[![Codecov test coverage](https://codecov.io/gh/ropengov/geodk/graph/badge.svg)](https://app.codecov.io/gh/ropengov/geodk)
[![Project Status: WIP – Development in progress](https://www.repostatus.org/badges/latest/wip.svg)](https://www.repostatus.org/#wip)
[![rOG-badge](https://ropengov.github.io/rogtemplate/reference/figures/ropengov-badge.svg)](https://ropengov.org/)

`{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()
```