diff --git a/DESCRIPTION b/DESCRIPTION index 9692b2b..0e64034 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -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"), diff --git a/NAMESPACE b/NAMESPACE index f6dddf6..4ca28ce 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -1,5 +1,6 @@ # Generated by roxygen2: do not edit by hand +export(get_levels) export(plot_denmark) export(plot_municipalities) export(plot_regions) diff --git a/R/data.R b/R/data.R new file mode 100644 index 0000000..e99e606 --- /dev/null +++ b/R/data.R @@ -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" diff --git a/R/get_levels.R b/R/get_levels.R index 2916d25..c3ae308 100644 --- a/R/get_levels.R +++ b/R/get_levels.R @@ -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", diff --git a/data-raw/data.R b/data-raw/data.R new file mode 100644 index 0000000..dd992fa --- /dev/null +++ b/data-raw/data.R @@ -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) diff --git a/data/municipalities.rda b/data/municipalities.rda new file mode 100644 index 0000000..b2de27b Binary files /dev/null and b/data/municipalities.rda differ diff --git a/data/regions.rda b/data/regions.rda new file mode 100644 index 0000000..d805771 Binary files /dev/null and b/data/regions.rda differ diff --git a/man/get_levels.Rd b/man/get_levels.Rd new file mode 100644 index 0000000..207f771 --- /dev/null +++ b/man/get_levels.Rd @@ -0,0 +1,19 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/get_levels.R +\name{get_levels} +\alias{get_levels} +\title{Get all available levels} +\usage{ +get_levels() +} +\value{ +This funciton returns all available levels for the \verb{plot_*} +functions. +} +\description{ +Get all available levels +} +\examples{ +get_levels() + +} diff --git a/man/municipalities.Rd b/man/municipalities.Rd new file mode 100644 index 0000000..a10b612 --- /dev/null +++ b/man/municipalities.Rd @@ -0,0 +1,29 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/data.R +\docType{data} +\name{municipalities} +\alias{municipalities} +\title{Danish municipalities} +\format{ +\subsection{\code{municipalities}}{ + +An object of classes \code{sf} and \code{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} +} +} +} +\usage{ +municipalities +} +\description{ +A \code{sf} dataset providing geometry for the danish municipalities +} +\keyword{datasets} diff --git a/man/regions.Rd b/man/regions.Rd new file mode 100644 index 0000000..2f31fc5 --- /dev/null +++ b/man/regions.Rd @@ -0,0 +1,28 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/data.R +\docType{data} +\name{regions} +\alias{regions} +\title{Danish regions} +\format{ +\subsection{\code{regions}}{ + +An object of classes \code{sf} and \code{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} +} +} +} +\usage{ +regions +} +\description{ +A \code{sf} dataset providing geometry for the danish regions +} +\keyword{datasets} diff --git a/pkgdown/_pkgdown.yml b/pkgdown/_pkgdown.yml index db98f82..d984a10 100644 --- a/pkgdown/_pkgdown.yml +++ b/pkgdown/_pkgdown.yml @@ -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