Type: | Package |
Title: | Visualization Tools for German Regional Data |
Version: | 0.1.0 |
Description: | Provides functions to download, process, and visualize German geospatial data across administrative levels, including states, districts, and municipalities. Supports interactive tables and customized maps using built-in or external datasets. Official shapefiles are accessed from the German Federal Agency for Cartography and Geodesy (BKG) https://gdz.bkg.bund.de/, licensed under dl-de/by-2-0 https://www.govdata.de/dl-de/by-2-0. |
License: | MIT + file LICENSE |
Encoding: | UTF-8 |
LazyData: | true |
URL: | https://codeberg.org/BBEdata/DEplotting |
BugReports: | https://codeberg.org/BBEdata/DEplotting/issues |
Imports: | dplyr, ggplot2, grDevices, grid, magrittr, patchwork, rlang, scales, sf, stringr, utils, data.table, DT |
RoxygenNote: | 7.3.2 |
NeedsCompilation: | no |
Packaged: | 2025-05-30 09:45:39 UTC; l.hoxha |
Author: | Leona Hoxha |
Maintainer: | Jannis Burkhard <j.burkhard@dipf.de> |
Repository: | CRAN |
Date/Publication: | 2025-06-03 09:40:05 UTC |
Download Geodata
Description
Downloads and unzips shapefiles from the official repository of the German Federal Agency for Cartography and Geodesy (BKG) for a specified range of years. The shapefiles are saved into a user-specific directory (tools::R_user_dir("DEplotting", "data")
). Downloading these files may take some time, but it is necessary for other functions in this package to work properly. Already downloaded years are detected and not re-downloaded.
Usage
download_geo(start_year = 1998, end_year = 2022)
Arguments
start_year |
Integer. The starting year for downloading geodata (default is 1998). |
end_year |
Integer. The ending year for downloading geodata (default is 2022). |
Details
Each shapefile folder for a single year is approximately 114 MB. The total download size for all 25 years can reach approximately 2.85 GB.
After running download_geo()
once, it is recommended to run it again to verify that all selected years were downloaded successfully. Any years that are already present will be skipped, and the function will attempt to download only the missing or previously failed ones.
The shapefiles accessed by this function are provided by the German Federal Agency for Cartography and Geodesy (BKG). These data are licensed under the Data License Germany – attribution – Version 2.0 (dl-de/by-2-0). For more information, see https://www.govdata.de/dl-de/by-2-0.
Value
No return value. Side effect: downloads and unzips shapefiles, prints progress messages, and stores the data locally.
See Also
list_codes
, map_plot
, load_geodata
Examples
download_geo(2022, 2022)
Look Up Administrative Codes (AGS) for German Regions
Description
Displays an interactive table for identifying official administrative codes (AGS) of municipalities (Gemeinden), districts (Kreise), and federal states (Länder) in Germany. The function loads and processes shapefiles for a given year, merges them across administrative levels, and presents a searchable datatable with names and AGS codes for each region.
Usage
list_codes(year)
Arguments
year |
Integer. Year of the geodata (must be between 1998 and 2022). |
Value
A DT::datatable
object showing merged geospatial metadata with municipality, district, and state names and their respective AGS codes.
Examples
list_codes(year = 2022)
Load Processed Geodata
Description
Loads shapefiles of states (Länder: LAN), districts (Kreise, kreisfreie Städte: KRS), and municipalities (Gemeinde: GEM) for a given year. The shapefiles are processed and assigned to the global environment as vg250_lan
, vg250_krs
, and vg250_gem
. This function is useful if you want to use the shapefiles with other R packages to plot your data.
Usage
load_geodata(year)
Arguments
year |
Integer. The year of geodata to load (must be between 1998 and 2022). |
Value
No return value. This function assigns the spatial datasets vg250_lan
, vg250_krs
, and vg250_gem
to the global environment using <<-
.
Examples
# Load the geodata from year 2015 into the R environment
load_geodata(year = 2015)
Plot Regionalized Data on Maps of Germany
Description
Visualizes regional data by creating maps of Germany. Currently supports states (Länder), districts (Kreise, kreisfreie Städte), and municipalities (Gemeinde). Can be used to plot any lower level within a higher one, e.g. states within Germany or municipalities within a district.
Usage
map_plot(
data,
var,
map_section = "",
level = "",
add_labels,
year,
geo_year,
palette = ""
)
Arguments
data |
Data frame. The dataset containing the variable to be plotted. |
var |
Character. The name of the variable (column) in |
map_section |
Character vector of AGS codes or federal state shortcuts. Used to define the outer boundaries of the map. Shortcuts are available for Germany ("DE") and for each federal state (e.g., "BE" for Berlin). For other areas, providing an AGS code is necessary, which can be looked up using the |
level |
Character "land", "kreis", or "gemeinde". Used to define the inner boundaries, i.e. the areas which will be plotted within |
add_labels |
Logical. Whether to show numeric labels on the map. If TRUE, will not only fill each area specified in |
year |
Integer. Year of the data to be plotted. Will detect the respective column in |
geo_year |
Integer or "". Year of the geodata to use; defaults to "" for which the year provided in |
palette |
Character. Name of the color palette ("Red", "Blue", etc.). |
Value
A ggplot2 object visualizing the provided regional data. Can be further customized.
Examples
data <- nstudents2022 # provide the data you want to plot here
# Example: Plotting the number of students in Germany by state
map_plot(
data = data, # the dataset containing the variable to plot
var = "nStudents", # the variable to plot
map_section = "DE", # plot entire Germany
level = "land", # plot by state
add_labels = FALSE, # do not show labels
year = 2022, # year of the data
geo_year = "", # use the same year for geodata
palette = "red" # use red color palette
)
Example Educational Data (2022)
Description
A small sample dataset containing the number of students per German state (Länder) for the year 2022.
Usage
nstudents2022
Format
A data frame with 16 rows and 4 columns:
- Year
The year of observation (2022)
- ARS
Administrative regional code (2-digit code for German states)
- Name
Name of the German state
- nStudents
Total number of secondary school students in each state
Source
Statistisches Bundesamt (Destatis), Genesis-Online; Data licence dl-de/by-2-0 [https://www.govdata.de/dl-de/by-2-0]