Skip to content

Commit

Permalink
Add built in datasets to the package
Browse files Browse the repository at this point in the history
  • Loading branch information
aleksanderbl29 committed Nov 24, 2024
1 parent 533e1c3 commit 65f3696
Show file tree
Hide file tree
Showing 11 changed files with 172 additions and 0 deletions.
1 change: 1 addition & 0 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ Package: geodk
Type: Package
Title: Access Danish Geospatial Data
Version: 0.0.0.9000
Date: 2024-11-24
Authors@R:
person("Aleksander", "Bang-Larsen", , "contact@aleksanderbl.dk",
role = c("aut", "cre", "cph"),
Expand Down
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Generated by roxygen2: do not edit by hand

export(get_levels)
export(plot_denmark)
export(plot_municipalities)
export(plot_regions)
Expand Down
34 changes: 34 additions & 0 deletions R/data.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#' Danish regions
#'
#' A `sf` dataset providing geometry for the danish regions
#'
#' @format ## `regions`
#' An object of classes `sf` and `data.frame` with 5 rows and 8 columns:
#' \describe{
#' \item{code}{Unique code}
#' \item{name}{The Danish name of the region}
#' \item{nuts2}{EU nuts division}
#' \item{source_changed}{When was the source last changed on the data-provider's side}
#' \item{visualcenter_x, visualcenter_y}{Visual center of the polygon in WGS84}
#' \item{geometry}{Polygons for each region}
#' \item{last_update}{When was the data in the package last updated by maintainers}
#' }
"regions"

#' Danish municipalities
#'
#' A `sf` dataset providing geometry for the danish municipalities
#'
#' @format ## `municipalities`
#' An object of classes `sf` and `data.frame` with 99 rows and 9 columns:
#' \describe{
#' \item{code}{Unique code}
#' \item{name}{The Danish name of the municipality}
#' \item{region_code}{The unique code of the region that this municipality is located in}
#' \item{region_name}{The name of the region that this municipality is located in}
#' \item{source_changed}{When was the source last changed on the data-provider's side}
#' \item{visualcenter_x, visualcenter_y}{Visual center of the polygon in WGS84}
#' \item{geometry}{Polygons for each municipality}
#' \item{last_update}{When was the data in the package last updated by maintainers}
#' }
"municipalities"
9 changes: 9 additions & 0 deletions R/get_levels.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
#' Get all available levels
#'
#' @returns This funciton returns all available levels for the `plot_*`
#' functions.
#'
#' @export
#' @examples
#' get_levels()
#'
get_levels <- function() {
levels <- c(
"regioner",
Expand Down
26 changes: 26 additions & 0 deletions data-raw/data.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
regions <- dawaR::get_map_data("regioner") |>
dplyr::rename(code = kode,
name = navn,
last_changed = ændret,
visualcenter_x = visueltcenter_x,
visualcenter_y = visueltcenter_y,
source_changed = ændret) |>
dplyr::select(-c(dagi_id, geo_ændret, geo_version)) |>
dplyr::mutate(last_update = lubridate::today())

usethis::use_data(regions, compress = "xz", overwrite = TRUE)

municipalities <- dawaR::get_map_data("kommuner") |>
dplyr::rename(code = kode,
name = navn,
region_code = regionskode,
region_name = regionsnavn,
last_changed = ændret,
visualcenter_x = visueltcenter_x,
visualcenter_y = visueltcenter_y,
source_changed = ændret) |>
dplyr::select(-c(dagi_id, geo_ændret, geo_version,
udenforkommuneinddeling)) |>
dplyr::mutate(last_update = lubridate::today())

usethis::use_data(municipalities, compress = "xz", overwrite = TRUE)
Binary file added data/municipalities.rda
Binary file not shown.
Binary file added data/regions.rda
Binary file not shown.
19 changes: 19 additions & 0 deletions man/get_levels.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 29 additions & 0 deletions man/municipalities.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 28 additions & 0 deletions man/regions.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 25 additions & 0 deletions pkgdown/_pkgdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,28 @@ template:
authors:
Aleksander Bang-Larsen:
href: https://aleksanderbl.dk

reference:
- title: Plotting
desc: >
Convenient functions for plotting one or more dansih geographic parts.
All of these function in the same way and allow you to provide a single
name or a vector of names of the areas you would like to plot as well
as fill and color options.
contents:
- starts_with("plot")

- title: Data
desc: >
Datasets that are provided with the package. At some point the plotting
functions will default to use these datasets to spare you, as the user,
of the waiting times of the official API.
contents:
- regions
- municipalities

- title: Misc
desc: >
Miscellanious functions
contents:
- get_levels

0 comments on commit 65f3696

Please # to comment.