The hardware and bandwidth for this mirror is donated by dogado GmbH, the Webhosting and Full Service-Cloud Provider. Check out our Wordpress Tutorial.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]dogado.de.

DEplotting

Repository maintained by Jannis Burkhard (bildungsbericht-daten@dipf.de)

DEplotting is an R package for downloading and processing geospatial data to visualize German regional data (states/Länder: LAN, districts/Kreis[-freie Städte]: KRS, municipalities/Gemeinden: GEM). It simplifies working with shapefiles provided by the German Federal Agency for Cartography and Geodesy (BKG), enabling the creation of maps and tables across administrative regions.


1. download_geo() – Download Geodata

Purpose: Automatically downloads and unzips shapefiles from the official BKG portal (1998–2022) into a user-specific directory (using tools::R_user_dir("DEplotting", "data")).

Features

Usage

download_geo()
download_geo(start_year = 2000, end_year = 2010)

2. list_codes() – Interactive Table of Merged Geodata

Purpose: Can be used to look up regional codes of administrative areas for a specified year by returning an interactive HTML table with administrative metadata.

Features

Usage

list_codes(year = 2022)

3. map_plot() – Visualize Regional Data on a Map

Purpose: Creates choropleth maps of German administrative areas (states, districts, or municipalities) using user-provided data.

Features

Arguments

Usage

map_plot(
  data = yourdata,
  var = "yourtargetvariable",
  map_section = "DE",  # or state codes like "BB", "BE"
  level = "land",
  add_labels = FALSE,
  year = 2022,
  geo_year = "",
  palette = "red"
)

Example usage with built-in dataset

In addition to loading external CSV files, the map_plot() function can also be used with a dataset included in the package. The following example demonstrates how to visualize the number of students using the built-in nstudents2022 dataset. This is especially useful for quick testing or demonstrations without needing to prepare your own data files. The example plots student counts by state for all of Germany in 2022, using a red color palette.

# Load the built-in dataset
data(nstudents2022, package = "DEplotting")

# Generate the map
map_plot(
  data = nstudents2022,
  var = "nStudents",
  map_section = "DE",  # DE stands for the whole Germany
  level = "land",
  add_labels = FALSE,
  year = 2022,
  geo_year = "",
  palette = "red"
)

4. load_geodata() – Load and Assigns Shapefiles to the R Environment

Purpose: Assigns Shapefiles to the R environment so that they can be used with other plotting packages.

Features

Usage

load_geodata(year = 2015)

# Objects available in the global environment:
vg250_lan  # States/Länder
vg250_krs  # Districts/Kreis(-freie Städte)
vg250_gem  # Municipalities/Gemeinden

📌 Maintenance Note

This package is based on BKG geodata from 1998 to 2022. If new shapefiles become available (e.g., for 2023 or beyond), updates may be required for: - Path definitions in get_shapefile_path() - Naming conventions for LAN/KRS/GEM layers

Appendix A: German State Abbreviations

State Name Abbreviation
Baden-Württemberg BW
Bavaria BY
Berlin BE
Brandenburg BB
Bremen HB
Hamburg HH
Hesse HE
Lower Saxony NI
Mecklenburg-Vorpommern MV
North Rhine-Westphalia NW
Rhineland-Palatinate RP
Saarland SL
Saxony SN
Saxony-Anhalt ST
Schleswig-Holstein SH
Thuringia TH
Entire Germany DE

These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.
Health stats visible at Monitor.