| Type: | Package |
| Title: | Download Official Spatial Data from Germany |
| Version: | 0.1.1 |
| Description: | Provides quick and easy access to official spatial data from Germany’s Federal Agency for Cartography and Geodesy (BKG)https://gdz.bkg.bund.de/. Interfaces various web feature services (WFS) and download servers. Allows retrieval, caching and filtering with a wide range of open geodata products, including administrative or non-administrative boundaries, land cover, elevation models, geographic names, and points of interest covering Germany. Can be particularly useful for linking regional statistics to their spatial representations and streamlining workflows that involve spatial data of Germany. |
| License: | MIT + file LICENSE |
| Encoding: | UTF-8 |
| LazyData: | true |
| RoxygenNote: | 7.3.2 |
| Depends: | R (≥ 3.5) |
| Imports: | cli, rlang, zip, httr2, xml2, sf |
| Suggests: | tibble, terra, arrow, ggplot2, knitr, rmarkdown, testthat (≥3.2.2) |
| Config/testthat/edition: | 3 |
| VignetteBuilder: | knitr |
| NeedsCompilation: | no |
| Packaged: | 2025-11-05 15:00:25 UTC; PC |
| Author: | Jonas Lieth |
| Maintainer: | Jonas Lieth <jonas.lieth@gesis.org> |
| Repository: | CRAN |
| Date/Publication: | 2025-11-09 16:10:09 UTC |
German administrative boundaries
Description
Threesf dataframes containing all geometries ofGerman districts, federal states, and the country, respectively. Thereference year is 2023.
Usage
bkg_krsbkg_statesbkg_germanyFormat
For the dataframe format, seebkg_admin.
An object of classsf (inherits fromtbl_df,tbl,data.frame) with 25 rows and 25 columns.
An object of classsf (inherits fromtbl_df,tbl,data.frame) with 7 rows and 25 columns.
Source
© BKG (2025) dl-de/by-2-0, data sources:https://sgx.geodatenzentrum.de/web_public/gdz/datenquellen/Datenquellen_vg_nuts.pdf
See Also
Other datasets:nuts_data
Examples
bkg_krsAdministrative areas
Description
Retrieve polygon geometries of administrative areas in Germany. Alladministrative levels are supported at different spatial resolutions.
bkg_admininterfaces a WFS that allows prefiltering butprovides no historical data and allows a maximum scale of 1:250,000.bkg_admin_archiveallows access to historical data buthas no prefiltering.bkg_admin_highres(vg25) allows access tohigh-resolution data going as low as 1:25,000 but allows no prefiltering.
These functions interface thevg* products of the BKG.
Usage
bkg_admin( ..., level = "krs", scale = c("250", "1000", "2500", "5000"), key_date = c("0101", "1231"), bbox = NULL, poly = NULL, predicate = "intersects", filter = NULL, epsg = 3035, properties = NULL, max = NULL)bkg_admin_archive( level = "krs", scale = c("250", "1000", "2500", "5000"), key_date = c("0101", "1231"), year = "latest", timeout = 120, update_cache = FALSE)bkg_admin_highres( level = "krs", year = "latest", layer = NULL, timeout = 600, update_cache = FALSE)Arguments
... | Used to construct CQL filters. Dot arguments accept an R-likesyntax that is converted to CQL queries internally. These queries basicallyconsist of a property name on the left, an aribtrary vector on the right,and an operator that links both sides. If multiple queries are provided,they will be chained with
To construct more complex queries, you can use the | ||||||||||||||||||||||||||||||
level | Administrative level to download. Must be one of | ||||||||||||||||||||||||||||||
scale | Scale of the geometries. Can be | ||||||||||||||||||||||||||||||
key_date | For | ||||||||||||||||||||||||||||||
bbox | An sf geometry or a boundary box vector of the format | ||||||||||||||||||||||||||||||
poly | An sf geometry. Used as a geometric filter to includeonly those geometries that relate to | ||||||||||||||||||||||||||||||
predicate | A spatial predicate that is used to relate the outputgeometries with the object specified in | ||||||||||||||||||||||||||||||
filter | A character string containing a valid CQL or XML filter. Thisstring is appended to the query constructed through | ||||||||||||||||||||||||||||||
epsg | An EPSG code specifying a coordinate reference system of theoutput. If you're unsure what this means, try running | ||||||||||||||||||||||||||||||
properties | Vector of columns to include in the output. | ||||||||||||||||||||||||||||||
max | Maximum number of results to return. | ||||||||||||||||||||||||||||||
year | Version year of the dataset. You can use | ||||||||||||||||||||||||||||||
timeout | Timeout value for the data download passed to | ||||||||||||||||||||||||||||||
update_cache | By default, downloaded files are cached in the | ||||||||||||||||||||||||||||||
layer | The |
Value
An sf dataframe with multipolygon geometries and different columnsdepending on the geometry type.Areal geometries generally have the following columns:
objid: Unique object identifierbeginn: Creation of the object in the DLMade: Integer representing the administrative level. Canbe one of1: Germany
2: Federal state
3: Governmental district
4: District
5: Administrative association
6: Municipality
gf: Integer representing the geofactor; whether an area is"structured" or not. Land is structured if it is part of a state or otheradministrative unit but is not further divided into administrative units.Can be one of1: Unstructured, waterbody
2: Structured, waterbody
3: Unstructured, land
4: Structured, land
bsg: Special areas, can be 1 (Germany) or 9 (Lake Constance)ars: Territorial code (Amtlicher Regionalschlüssel).The ARS is stuctured hierarchically as follows:Position 1-2: Federal state
Position 3: Government region
Position 4-5: District
Position 6-9: Administrative association
Position 10-12: Municipality
ags: Official municipality key (Amtlicher Gemeindeschlüssel).Related to the ARS but shortened to omit position 6 to 9. Structured asfollows:Position 1-2: Federal state
Position 3: Government region
Position 4-5: District
Position 6-8: Municipality
sdv_ars: ARS of the seat of administrationgen: Geographical namebez: Label of the administrative unitibz: Identifier of the labelbem: Comment on the labelnbd: Formation of the geographical name. Can be "ja" ifthe label is part of the name or "nein" otherwise.nuts: NUTS identifier based on the Eurostat regionalclassificationars_0: ARS identifier with trailing zeroesags_0: AGS identifier with trailing zeroeswsk: Legally relevant date for the effectiveness of administrative changessn_l: Federal state component of the ARSsn_r: Governmental district component of the ARSsn_k: District component of the ARSsn_v1: First part of the administrative association component of the ARSsn_v2: Second part of the administrative association component of the ARSsn_g: Municipality component of the ARSfk_3: Purpose of the third key position. If"R", indicates thegovernment region, if"K", indicates the districtdkm_id: Identifier in the digital landscape model (DLM250)ewz: Number of inhabitantskfl: Land register area in square kilometers
Boundary geometries ("li") can have additional columns:
agz: Type of border. Can be one of1: National border
2: State border
3: Governmental district border
4: District border
5: Administrative association border
6: Municipality border
9: Coastline
rdg: Legal definition of a border. Can be 1 (determined),2 (not determined) or 9 (coastline)gm5: Border characteristic of administrative associationborders (AGZ 5). Used to describe the purpose of these borders. Canbe 0 (characteristics by AGZ) or 8 (non-association border)gmk: Border characteristic by coast/ocean. Specifies whethera border runs a long a waterbody. Can be one of7: borders on the ocean
8: auxiliary borders on the ocean
9: borders at the coastline
0: no characteristics
dlm_id: Identifier in the digital landscape model (DLM250)
Point geometries ("pk") have the following additional columns:
otl: Name of the locality in the digital landscale model (DLM250)lon_dez: Decimal longitudelat_dez: Decimal latitudelon_gms: Geographical longitudelat_gms: Geographical latitude
Query language
By default, WFS requests use CQL (Contextual Query Language) queries forsimplicity. CQL queries only work together with GET requests. This meansthat when the URL is longer than 2048 characters, they fail.While POST requests are much more flexible and able to accommodate longqueries, XML is really a pain to work with and I'm not confident in myapproach to construct XML queries. You can control whether to send GET orPOST requests by settingoptions(ffm_query_language = "XML")oroptions(ffm_query_language = "CQL").
See Also
bkg_nuts for retrieving EU administrative areas
bkg_admin_hierarchy for the administrative hierarchy
bkg_ror,bkg_grid,bkg_kfz,bkg_authorities for non-administrative regions
Datasets:admin_data,nuts_data
Examples
# You can use R-like operators to query the WFSbkg_admin(ags %LIKE% "05%") # districts in NRWbkg_admin(sn_l == "05") # does the same thingbkg_admin(gen %LIKE% "Ber%") # districts starting with Ber*# To query population and area, the key date must be December 31bkg_admin(ewz > 500000, key_date = "1231") # districts over 500k peoplebkg_admin(kfl <= 100, key_date = "1231") # districts with low land register area# Using `gf == 9`, you can exclude waterbodies like oceansstates <- bkg_admin(scale = "5000", level = "lan", gf == 9)plot(states$geometry)# Download historical databkg_admin_archive(scale = "5000", level = "sta", year = "2021")# Download high-resolution data (takes a long time!)bkg_admin_highres(level = "lan")Administrative hierarchy
Description
Retrieve polygon geometries of municipalities in Germany with details ontheir relationships to administrative areas of higher levels in theterritorial hierarchy. The output of this functions contains the identifiersand names of the NUTS1 to NUTS3 areas that each municipality belongs to.
Usage
bkg_admin_hierarchy( key_date = c("0101", "1231"), year = "latest", timeout = 120, update_cache = FALSE)Arguments
key_date | For |
year | Version year of the dataset. You can use |
timeout | Timeout value for the data download passed to |
update_cache | By default, downloaded files are cached in the |
Value
An sf tibble with multipolygon geometries similar to the outputofbkg_admin(level = "gem"). The tibble additionally containscolumnsNUTS*_CODE andNUTS*_NAME giving the identifiers andnames of the administrative areas the municipalities belong to.
Examples
bkg_admin_hierarchy()Official keys
Description
Retrieve geographical names associated with official municipality keysand regional keys. To retrieve their polygon geometries, seebkg_admin.
These functions interface thewfs_gnde product of the BKG.
Usage
bkg_ags(..., filter = NULL, properties = NULL, max = NULL)bkg_ars(..., filter = NULL, properties = NULL, max = NULL)Arguments
... | Used to construct CQL filters. Dot arguments accept an R-likesyntax that is converted to CQL queries internally. These queries basicallyconsist of a property name on the left, an aribtrary vector on the right,and an operator that links both sides. If multiple queries are provided,they will be chained with
To construct more complex queries, you can use the | ||||||||||||||||||||||||||||||
filter | A character string containing a valid CQL or XML filter. Thisstring is appended to the query constructed through | ||||||||||||||||||||||||||||||
properties | Vector of columns to include in the output. | ||||||||||||||||||||||||||||||
max | Maximum number of results to return. |
Value
A dataframe containing the respective identifier and geographicalnames related to their state, government region, district and municipality.bkg_ars additionally returns the name of the administrativeassociation.
Query language
While other WFS interfaces likebkg_admin allow queryingusing CQL or XML,bkg_ags andbkg_ars (using the GNDE service)ONLY support XML. This has implications for the allowed query filters(seewfs_filter).
Examples
# Either get geographical names for identifiersbkg_ars(ars == "01")# ... or identifiers for geographical namesbkg_ars(gemeinde == "Köln")Airports
Description
Retrieve international, regional, and special airports in Germany. Smalllanding sites are not included.
These functions interface thewfs_poi_open product of the BKG.
Usage
bkg_airports( ..., bbox = NULL, poly = NULL, predicate = "intersects", filter = NULL, epsg = 3035, properties = NULL, max = NULL)Arguments
... | Used to construct CQL filters. Dot arguments accept an R-likesyntax that is converted to CQL queries internally. These queries basicallyconsist of a property name on the left, an aribtrary vector on the right,and an operator that links both sides. If multiple queries are provided,they will be chained with
To construct more complex queries, you can use the | ||||||||||||||||||||||||||||||
bbox | An sf geometry or a boundary box vector of the format | ||||||||||||||||||||||||||||||
poly | An sf geometry. Used as a geometric filter to includeonly those geometries that relate to | ||||||||||||||||||||||||||||||
predicate | A spatial predicate that is used to relate the outputgeometries with the object specified in | ||||||||||||||||||||||||||||||
filter | A character string containing a valid CQL or XML filter. Thisstring is appended to the query constructed through | ||||||||||||||||||||||||||||||
epsg | An EPSG code specifying a coordinate reference system of theoutput. If you're unsure what this means, try running | ||||||||||||||||||||||||||||||
properties | Vector of columns to include in the output. | ||||||||||||||||||||||||||||||
max | Maximum number of results to return. |
Value
A dataframe containing the following columns:
name: Geographical name of the POIgemeinde: Municipality nameverwaltung: Administrative association namekreis: District nameregierungs: Government region namebundesland: Federal state namepoi_id: Unique primary key of a point of interesticao_code: ICAO code of the airporttyp: Type of airport. Can be one of the following:international: International airport
regional: Regional airport
Sonderflughafen: Special airport
Query language
By default, WFS requests use CQL (Contextual Query Language) queries forsimplicity. CQL queries only work together with GET requests. This meansthat when the URL is longer than 2048 characters, they fail.While POST requests are much more flexible and able to accommodate longqueries, XML is really a pain to work with and I'm not confident in myapproach to construct XML queries. You can control whether to send GET orPOST requests by settingoptions(ffm_query_language = "XML")oroptions(ffm_query_language = "CQL").
See Also
Other points of interest:bkg_crossings(),bkg_heliports(),bkg_kilometrage(),bkg_seaports(),bkg_stations(),bkg_trauma_centers()
Examples
# Get all airports in NRWairports <- bkg_airports(ars %LIKE% "05%")nrw <- bkg_admin(level = "lan", sn_l == "05")plot(nrw$geometry)plot(airports$geometry, add = TRUE, pch = 16)Area code regions
Description
Retrieves area code regions (Vorwahlgebiete) in Germany. Area coderegions are based on the number of registered telephone numbers.
Usage
bkg_area_codes( ..., bbox = NULL, poly = NULL, predicate = "intersects", filter = NULL, epsg = 3035, max = NULL)Arguments
... | Used to construct CQL filters. Dot arguments accept an R-likesyntax that is converted to CQL queries internally. These queries basicallyconsist of a property name on the left, an aribtrary vector on the right,and an operator that links both sides. If multiple queries are provided,they will be chained with
To construct more complex queries, you can use the | ||||||||||||||||||||||||||||||
bbox | An sf geometry or a boundary box vector of the format | ||||||||||||||||||||||||||||||
poly | An sf geometry. Used as a geometric filter to includeonly those geometries that relate to | ||||||||||||||||||||||||||||||
predicate | A spatial predicate that is used to relate the outputgeometries with the object specified in | ||||||||||||||||||||||||||||||
filter | A character string containing a valid CQL or XML filter. Thisstring is appended to the query constructed through | ||||||||||||||||||||||||||||||
epsg | An EPSG code specifying a coordinate reference system of theoutput. If you're unsure what this means, try running | ||||||||||||||||||||||||||||||
max | Maximum number of results to return. |
Value
An sf dataframe containing polygon geometries and the area code(vorwahl) associated with the region.
Query language
While other WFS interfaces likebkg_admin allow queryingusing CQL or XML,bkg_area_codes ONLY supports XML. This hasimplications for the allowed query filters (seewfs_filter).
Examples
vorwahlen <- bkg_area_codes(vorwahl %LIKE% "0215%")plot(vorwahlen$geometry)Regions of authority
Description
Retrieve regions of administrative responsibility for job centers,employment agencies, offices of employment agencies, regionaldirectorates of the Federal Employment Agency as well as local, regional,and higher regional courts.
This function interfaces thewfs_bzb-open product of the BKG.
Usage
bkg_authorities( authority, ..., bbox = NULL, poly = NULL, predicate = "intersects", filter = NULL, epsg = 3035, properties = NULL, max = NULL)Arguments
authority | Type of authority for which to retrieve regions ofresponsibility. Must be one of | ||||||||||||||||||||||||||||||
... | Used to construct CQL filters. Dot arguments accept an R-likesyntax that is converted to CQL queries internally. These queries basicallyconsist of a property name on the left, an aribtrary vector on the right,and an operator that links both sides. If multiple queries are provided,they will be chained with
To construct more complex queries, you can use the | ||||||||||||||||||||||||||||||
bbox | An sf geometry or a boundary box vector of the format | ||||||||||||||||||||||||||||||
poly | An sf geometry. Used as a geometric filter to includeonly those geometries that relate to | ||||||||||||||||||||||||||||||
predicate | A spatial predicate that is used to relate the outputgeometries with the object specified in | ||||||||||||||||||||||||||||||
filter | A character string containing a valid CQL or XML filter. Thisstring is appended to the query constructed through | ||||||||||||||||||||||||||||||
epsg | An EPSG code specifying a coordinate reference system of theoutput. If you're unsure what this means, try running | ||||||||||||||||||||||||||||||
properties | Vector of columns to include in the output. | ||||||||||||||||||||||||||||||
max | Maximum number of results to return. |
Value
An sf tibble with multipolygon geometries and the followingcolumns:
id: Identifier of the authority regiondst_id: Identifier of the authority officeuebergeord: Name of the superior authorityname: Name of the authority
Query language
By default, WFS requests use CQL (Contextual Query Language) queries forsimplicity. CQL queries only work together with GET requests. This meansthat when the URL is longer than 2048 characters, they fail.While POST requests are much more flexible and able to accommodate longqueries, XML is really a pain to work with and I'm not confident in myapproach to construct XML queries. You can control whether to send GET orPOST requests by settingoptions(ffm_query_language = "XML")oroptions(ffm_query_language = "CQL").
See Also
Other non-administrative regions:bkg_grid,bkg_kfz(),bkg_ror()
Examples
# Get only local courts that are subordinates of the regional court Cottbusbkg_authorities( authority = "local_courts", uebergeord %LIKE% "%Cottbus", uebergeord %LIKE% "Landgericht%")Corine Land Cover
Description
Retrieve land cover polygons in Germany based on the CorineLand Cover (CLC) nomenclature.Corine Land Coveris a way to project by the European Commission to consistenly classifyboth land cover and land use.
This function interfaces thewfs_clc5_* products of the BKG.
Usage
bkg_clc( ..., year = "2018", bbox = NULL, poly = NULL, predicate = "intersects", filter = NULL, epsg = 3035, properties = NULL, max = NULL)Arguments
... | Used to construct CQL filters. Dot arguments accept an R-likesyntax that is converted to CQL queries internally. These queries basicallyconsist of a property name on the left, an aribtrary vector on the right,and an operator that links both sides. If multiple queries are provided,they will be chained with
To construct more complex queries, you can use the | ||||||||||||||||||||||||||||||
year | Version year of the dataset. You can use | ||||||||||||||||||||||||||||||
bbox | An sf geometry or a boundary box vector of the format | ||||||||||||||||||||||||||||||
poly | An sf geometry. Used as a geometric filter to includeonly those geometries that relate to | ||||||||||||||||||||||||||||||
predicate | A spatial predicate that is used to relate the outputgeometries with the object specified in | ||||||||||||||||||||||||||||||
filter | A character string containing a valid CQL or XML filter. Thisstring is appended to the query constructed through | ||||||||||||||||||||||||||||||
epsg | An EPSG code specifying a coordinate reference system of theoutput. If you're unsure what this means, try running | ||||||||||||||||||||||||||||||
properties | Vector of columns to include in the output. | ||||||||||||||||||||||||||||||
max | Maximum number of results to return. |
Value
An sf dataframe with polygon geometries and the following columns:
clc*: CLC land cover classes for the given year. An overviewof all CLC classes can be found in theCopernicus documentation.shape_length: Circumference of the polygon in metersshape_area: Area of the polygon in square meters
Query language
By default, WFS requests use CQL (Contextual Query Language) queries forsimplicity. CQL queries only work together with GET requests. This meansthat when the URL is longer than 2048 characters, they fail.While POST requests are much more flexible and able to accommodate longqueries, XML is really a pain to work with and I'm not confident in myapproach to construct XML queries. You can control whether to send GET orPOST requests by settingoptions(ffm_query_language = "XML")oroptions(ffm_query_language = "CQL").
See Also
Examples
# Get glaciers in Germanybkg_clc(clc18 == "335")# Get all coastal wetlandsbkg_clc(clc18 %LIKE% "42%")# Get only wetlands in Lower Saxonyrlang::local_options(ffm_query_language = "xml")lowsax <- bkg_admin(level = "lan", scale = "5000", sn_l == "03", gf == 9)wetlands <- bkg_clc(clc18 %LIKE% "4%", poly = lowsax)plot(lowsax$geometry)plot(wetlands$geometry, add = TRUE)Border crossings
Description
Retrieve border crossings in Germany. A road is a border crossing if ittouches an international border and it continues on the foreign side.This includes ferry connections but not dirt roads.
Usage
bkg_crossings( ..., bbox = NULL, poly = NULL, predicate = "intersects", filter = NULL, epsg = 3035, properties = NULL, max = NULL)Arguments
... | Used to construct CQL filters. Dot arguments accept an R-likesyntax that is converted to CQL queries internally. These queries basicallyconsist of a property name on the left, an aribtrary vector on the right,and an operator that links both sides. If multiple queries are provided,they will be chained with
To construct more complex queries, you can use the | ||||||||||||||||||||||||||||||
bbox | An sf geometry or a boundary box vector of the format | ||||||||||||||||||||||||||||||
poly | An sf geometry. Used as a geometric filter to includeonly those geometries that relate to | ||||||||||||||||||||||||||||||
predicate | A spatial predicate that is used to relate the outputgeometries with the object specified in | ||||||||||||||||||||||||||||||
filter | A character string containing a valid CQL or XML filter. Thisstring is appended to the query constructed through | ||||||||||||||||||||||||||||||
epsg | An EPSG code specifying a coordinate reference system of theoutput. If you're unsure what this means, try running | ||||||||||||||||||||||||||||||
properties | Vector of columns to include in the output. | ||||||||||||||||||||||||||||||
max | Maximum number of results to return. |
Value
A dataframe with the following columns:
name: Geographical name of the POIgemeinde: Municipality nameverwaltung: Administrative association namekreis: District nameregierungs: Government region namebundesland: Federal state nameort: Name of the nearest placestrasse: Number or label of the border-crossing streettyp: Type of checkpoint; always "Straßenverkehr"
Query language
By default, WFS requests use CQL (Contextual Query Language) queries forsimplicity. CQL queries only work together with GET requests. This meansthat when the URL is longer than 2048 characters, they fail.While POST requests are much more flexible and able to accommodate longqueries, XML is really a pain to work with and I'm not confident in myapproach to construct XML queries. You can control whether to send GET orPOST requests by settingoptions(ffm_query_language = "XML")oroptions(ffm_query_language = "CQL").
See Also
Other points of interest:bkg_airports(),bkg_heliports(),bkg_kilometrage(),bkg_seaports(),bkg_stations(),bkg_trauma_centers()
Examples
# Get all border crossings in Bavariacrossings <- bkg_crossings(bundesland == "Bayern")plot(crossings$geometry, pch = 16)Digital elevation model
Description
Retrieve the digital elevation model (DEM) for the territory of Germany.
Usage
bkg_dem(bbox = NULL, interpolation = NULL, epsg = 3035)Arguments
bbox | An sf geometry or a boundary box vector of the format |
interpolation | Interpolation method to preprocess the raster.Can be |
epsg | An EPSG code specifying a coordinate reference system of theoutput. If you're unsure what this means, try running |
Value
ASpatRaster containing elevation data.
Examples
library(sf)# Elevation around Hanoverhan <- st_sfc(st_point(c(9.738611, 52.374444)), crs = 4326)han <- st_buffer(st_transform(han, 3035), dist = 2000)dem <- bkg_dem(bbox = han)terra::plot(dem)Digital landscape model (DLM)
Description
Retrieve objects from the digital landscape model (DLM). DLMs are adescription of topographical objects of a landscape. Many other servicesfrom the BKG are derived from the DLM.
Although this function lets you download each feature type in the DLM, youstill need to know about what data is available and what the features in theoutput actually mean. Since the DLM gets pretty complicated, you are advisedto take a look at theGeoInfoDokobject type catalog.
This function interfaces thedlm* products of the BKG.
Usage
bkg_dlm( type, ..., shape = c("point", "line", "polygon"), scale = c("250", "1000"), bbox = NULL, poly = NULL, predicate = "intersects", filter = NULL, epsg = 3035, properties = NULL, max = NULL)Arguments
type | Feature type of the DLM. Can either be the identifier(e.g., 41010) or its description (e.g., Siedlungsflaeche). The descriptioncan either be prefixed with Note that not all feature types are available for all shapes (see the | ||||||||||||||||||||||||||||||
... | Used to construct CQL filters. Dot arguments accept an R-likesyntax that is converted to CQL queries internally. These queries basicallyconsist of a property name on the left, an aribtrary vector on the right,and an operator that links both sides. If multiple queries are provided,they will be chained with
To construct more complex queries, you can use the | ||||||||||||||||||||||||||||||
shape | Geometry type of the feature type. Must be one of | ||||||||||||||||||||||||||||||
scale | Scale of the geometries. Can be | ||||||||||||||||||||||||||||||
bbox | An sf geometry or a boundary box vector of the format | ||||||||||||||||||||||||||||||
poly | An sf geometry. Used as a geometric filter to includeonly those geometries that relate to | ||||||||||||||||||||||||||||||
predicate | A spatial predicate that is used to relate the outputgeometries with the object specified in | ||||||||||||||||||||||||||||||
filter | A character string containing a valid CQL or XML filter. Thisstring is appended to the query constructed through | ||||||||||||||||||||||||||||||
epsg | An EPSG code specifying a coordinate reference system of theoutput. If you're unsure what this means, try running | ||||||||||||||||||||||||||||||
properties | Vector of columns to include in the output. | ||||||||||||||||||||||||||||||
max | Maximum number of results to return. |
Value
An sf tibble with the geometry suggested byshape.The columns can vary depending of the selected feature type. The meaningsof the columns can also change depending on the feature type. Check outthe GeoInfoDok object type catalog for a detailed documentation of theDLM metadata. Some more general columns are included for all feature types;these include:
id: Identifier of an objectland: ISO-2 code of the country, usually DEmodellart: Model typeobjart: Feature type of the digital landscape model (DLM)objart_txt: Title of the feature typeobjid: Unique object identifierbeginn: Creation of the object in the DLMende: Deletion of the object from the DLMobjart_z: Object type of the composite object (ZUSO)objid_z: Object type of the composite object (ZUSO)
Query language
By default, WFS requests use CQL (Contextual Query Language) queries forsimplicity. CQL queries only work together with GET requests. This meansthat when the URL is longer than 2048 characters, they fail.While POST requests are much more flexible and able to accommodate longqueries, XML is really a pain to work with and I'm not confident in myapproach to construct XML queries. You can control whether to send GET orPOST requests by settingoptions(ffm_query_language = "XML")oroptions(ffm_query_language = "CQL").
See Also
Examples
# Retrieve all train tracks in Leipziglibrary(sf)lzg <- st_sfc(st_point(c(12.37475, 51.340333)), crs = 4326)lzg <- st_buffer(st_transform(lzg, 3035), dist = 10000, endCapStyle = "SQUARE")tracks <- bkg_dlm("Bahnstrecke", shape = "line", poly = lzg)tracksplot(lzg)plot(tracks$geometry, add = TRUE)# Filter all tracks that are not rail cargobkg_dlm("Bahnstrecke", shape = "line", poly = lzg, bkt == "1102")# Directly providing the identifier is fasterbkg_dlm("42014", shape = "line", poly = lzg)Geographical objects and endonyms
Description
Get geographic names including toponyms and endonyms.bkg_geonamesretrieves the geographical "objects" based on the digital landscape model(DLM). These objects contain a set of metadata and a national name identifier(NNID). These NNIDs can be used to join with the endonyms related to ageographical object (bkg_endonyms).
These functions interface thewfs_gnde product of the BKG.
Usage
bkg_geonames( ..., names = TRUE, ags = FALSE, dlm = FALSE, status = FALSE, bbox = NULL, poly = NULL, predicate = "intersects", filter = NULL, epsg = 3035, properties = NULL, max = NULL)bkg_endonyms(..., filter = NULL, properties = NULL, max = NULL)Arguments
... | Used to construct CQL filters. Dot arguments accept an R-likesyntax that is converted to CQL queries internally. These queries basicallyconsist of a property name on the left, an aribtrary vector on the right,and an operator that links both sides. If multiple queries are provided,they will be chained with
To construct more complex queries, you can use the | ||||||||||||||||||||||||||||||
names | If | ||||||||||||||||||||||||||||||
ags | If | ||||||||||||||||||||||||||||||
dlm | If | ||||||||||||||||||||||||||||||
status | If | ||||||||||||||||||||||||||||||
bbox | An sf geometry or a boundary box vector of the format | ||||||||||||||||||||||||||||||
poly | An sf geometry. Used as a geometric filter to includeonly those geometries that relate to | ||||||||||||||||||||||||||||||
predicate | A spatial predicate that is used to relate the outputgeometries with the object specified in | ||||||||||||||||||||||||||||||
filter | A character string containing a valid CQL or XML filter. Thisstring is appended to the query constructed through | ||||||||||||||||||||||||||||||
epsg | An EPSG code specifying a coordinate reference system of theoutput. If you're unsure what this means, try running | ||||||||||||||||||||||||||||||
properties | Vector of columns to include in the output. | ||||||||||||||||||||||||||||||
max | Maximum number of results to return. |
Details
These functions make use of the GN-DE WFS, just likebkg_ags,bkg_ars, andbkg_area_codes. The infrastructurebehind it is actually quite sophisticated and this function may not liveup to these standards. You can usebkg_feature_types andbkg_wfs to manually explore the service's endpoints ifrequired.
Value
A dataframe containing the following columns:
nnid: National name identifierlandesCode: Country identifier; 276 is Germany.beschreibung: Optional detailsgeoLaenge: Geographical longitudegeoBreite: Geographical latitudehoehe: Elevation above sea levelhoeheger: Computed elevation above sea levelgroesse: Undocumented, but I guess this relates to the suggested printsize of the labelsewz: Number of inhabitantsewzger: Computed number of inhabitantsags: Official municipality key (Amtlicher Gemeindeschlüssel).Related to the ARS but shortened to omit position 6 to 9. Structured asfollows:Position 1-2: Federal state
Position 3: Government region
Position 4-5: District
Position 6-8: Municipality
gemteil: Whether the place is part of a municipalityvirtuell: Whether the place is a real or virtual localityars: Territorial code (Amtlicher Regionalschlüssel).The ARS is stuctured hierarchically as follows:Position 1-2: Federal state
Position 3: Government region
Position 4-5: District
Position 6-9: Administrative association
Position 10-12: Municipality
Ifags = TRUE, adds the output ofbkg_ags. Ifdlm = TRUE, adds a columndlm_id containing identifiers ofbkg_dlm.
bkg_endonyms contains the following columns:
name: Name of the geographical objectgeschlecht: If applicable, the grammatical gender of a geographical name
These are also included in the output ofbkg_geonames ifnames = TRUE.
Query language
While other WFS interfaces likebkg_admin allow queryingusing CQL or XML,bkg_geonames andbkg_endonyms (using theGNDE service) ONLY support XML. This has implications for the allowedquery filters (seewfs_filter).
See Also
bkg_ags andbkg_ars for geographical namesof administrative areas
Examples
# Plot geographical objects in Colognelibrary(sf)library(ggplot2)cgn <- st_sfc(st_point(c(6.956944, 50.938056)), crs = 4326)cgn <- st_buffer(st_transform(cgn, 3035), dist = 500)cgn_names <- bkg_geonames(poly = cgn)st_geometry(cgn_names) <- st_centroid(st_geometry(cgn_names))cgn_names <- cgn_names[lengths(st_intersects(cgn_names, cgn)) > 0, ]ggplot(cgn_names) + geom_sf_text(aes(label = name)) + theme_void()INSPIRE grids
Description
Retrieve geometries of INSPIRE-compliant grid geometries (also called"GeoGitter").bkg_grid_fast() is much faster thanbkg_grid_full()by downloading heavily compressed versions grids. This happens at the costof data richness asbkg_grid_fast() only contains the geometries andnothing else. Note that thearrow package needs to be installed tousebkg_grid_fast().
Note that the output contains point geometries. Most of the times, youwant to work with rasters instead. To convert a given objectout,type the following (terra package required):
terra::rast(out)
These functions interface theGeoGitter product of the BKG.
Usage
bkg_grid_fast( year = c("2019", "2018", "2017", "2015"), resolution = c("100km", "10km", "5km", "1km", "250m", "100m"), timeout = 600, update_cache = FALSE)bkg_grid_full( year = "latest", resolution = c("100km", "10km", "5km", "1km", "250m", "100m"), timeout = 600, update_cache = FALSE)Arguments
year | Version of the grid. Can be |
resolution | Cell size of the grid. Can be |
timeout | Timeout value for the data download passed to |
update_cache | By default, downloaded files are cached in the |
Details
The following table gives a rough idea of how much less databkg_grid_fast needs to download for each resolution compared tobkg_grid_full.
| Size | fast | full |
| 100km | 0.78 kB | 933 kB |
| 10km | 2.68 kB | 1,015 kB |
| 5km | 3.53 kB | 1,253 kB |
| 1km | 28.7 kB | 5,249 kB |
| 500m | 133 kB | 15,902 kB |
| 250m | 289 kB | 53,900 kB |
| 100m | 1,420 kB | 291,000 kB |
Value
bkg_grid_fast returns an sf dataframe with point geometriesand no features.bkg_grid_full also returns point geometries butwith the following additional features:
x_sw: X coordinate of the South-West corner of a grid celly_sw: Y coordinate of the South-West corner of a grid cellf_staat: State area in the grid cell in square metersf_land: Land area in the grid cell in square metersf_wasser: Water area in the grid cell in square metersp_staat: Share of state area in the grid cellp_land: Share of land area in the grid cellp_wasser: Share of water area in the grid cellags: Official municipality key (Amtlicher Gemeindeschlüssel).Related to the ARS but shortened to omit position 6 to 9. Structured asfollows:Position 1-2: Federal state
Position 3: Government region
Position 4-5: District
Position 6-8: Municipality
Note thatags is only included for resolutions"100m" and"250m"
See Also
Other non-administrative regions:bkg_authorities(),bkg_kfz(),bkg_ror()
Examples
# Return a bare-bones version of the INSPIRE gridgrid <- bkg_grid_fast(year = "2019", resolution = "100km")# Return a fully detailed version insteadgrid_full <- bkg_grid_full(resolution = "5km")plot(grid)# Convert grid to SpatRasterif (requireNamespace("terra")) { library(terra) raster <- rast(vect(grid_full["p_wasser"]), type = "xyz") plot(raster, main = "Share of water area")}Heliports
Description
Get heliports in Germany. Based on data from third-party providers and imageclassification of aerial imagery.
Usage
bkg_heliports( ..., bbox = NULL, poly = NULL, predicate = "intersects", filter = NULL, epsg = 3035, properties = NULL, max = NULL)Arguments
... | Used to construct CQL filters. Dot arguments accept an R-likesyntax that is converted to CQL queries internally. These queries basicallyconsist of a property name on the left, an aribtrary vector on the right,and an operator that links both sides. If multiple queries are provided,they will be chained with
To construct more complex queries, you can use the | ||||||||||||||||||||||||||||||
bbox | An sf geometry or a boundary box vector of the format | ||||||||||||||||||||||||||||||
poly | An sf geometry. Used as a geometric filter to includeonly those geometries that relate to | ||||||||||||||||||||||||||||||
predicate | A spatial predicate that is used to relate the outputgeometries with the object specified in | ||||||||||||||||||||||||||||||
filter | A character string containing a valid CQL or XML filter. Thisstring is appended to the query constructed through | ||||||||||||||||||||||||||||||
epsg | An EPSG code specifying a coordinate reference system of theoutput. If you're unsure what this means, try running | ||||||||||||||||||||||||||||||
properties | Vector of columns to include in the output. | ||||||||||||||||||||||||||||||
max | Maximum number of results to return. |
Value
A dataframe with the following columns:
name: Geographical name of the POIgemeinde: Municipality nameverwaltung: Administrative association namekreis: District nameregierungs: Government region namebundesland: Federal state namecode: Identifier of the heliportname_bkg: Name of the landing site according to BKGname_dfs: Name of the landing size according to DeutscheFlugsicherung (DFS)airport_pk: Identifier according to the LFS aviation manualbefestigun: Pavement type of the landing site. Can be:befestigt: paved
teilweise befestigt: partially paved
unbefestigt: unpaved
kennzeich: Marking of the landing size. Can be:gekennzeichnet: marked
nicht gekennzeichnet: not marked
lage: Location of the landing size. Can be:D: Roof
F: Field
PG: Platform next to a hospital
W: Pasture
LP: Landing site
PP: Parking lot
LP / W: Paved landing size on pasture
F / W: Field or pasture
LP / Str.: Landing size next to a street
typ: Type of heliport. Can be:H: Heliport
HH: Heliport at a hospital
MH: Military heliport
typ2: Additional heliport type for landing sites with anair rescue station. Can be:HRLS: Helicopter air rescue station
ITH: Intensive transport helicopter
betreiber: Operator of the heliporthelikopter: Name of the helicopter belonging to theair rescue stationstatus: Whether the point geometry was edited by the BKG.Can be:Original: not edited
Verschoben: moved
neu: newly added
quelle: Source of the information. Can be:BKG: Own research by the BKG
DFS-Liste: Provided by DFS
LBA-Liste: Provided by the Federal Aviation Office (LBA)
MHW: Provided by the Medical Disaster Relief Organization (MHW)
RTH.Info: Provided by rth.info
Query language
By default, WFS requests use CQL (Contextual Query Language) queries forsimplicity. CQL queries only work together with GET requests. This meansthat when the URL is longer than 2048 characters, they fail.While POST requests are much more flexible and able to accommodate longqueries, XML is really a pain to work with and I'm not confident in myapproach to construct XML queries. You can control whether to send GET orPOST requests by settingoptions(ffm_query_language = "XML")oroptions(ffm_query_language = "CQL").
See Also
Other points of interest:bkg_airports(),bkg_crossings(),bkg_kilometrage(),bkg_seaports(),bkg_stations(),bkg_trauma_centers()
Examples
# Get only military heliportsbkg_heliports(typ == "MH")# Get only rooftop heliportsbkg_heliports(lage == "D")Vehicle registration plates
Description
Retrieve motor vehicle registration plate regions in Germany. Registrationplate regions are discerned by their area code(Unterscheidungszeichen) which indicate the place where a vehiclewas registered. These regions partially overlap with districts but are notentirely identical.
This function interfaces thewfs_kfz250 product of the BKG.
Usage
bkg_kfz( ..., bbox = NULL, poly = NULL, predicate = "intersects", filter = NULL, epsg = 3035, properties = NULL, max = NULL)Arguments
... | Used to construct CQL filters. Dot arguments accept an R-likesyntax that is converted to CQL queries internally. These queries basicallyconsist of a property name on the left, an aribtrary vector on the right,and an operator that links both sides. If multiple queries are provided,they will be chained with
To construct more complex queries, you can use the | ||||||||||||||||||||||||||||||
bbox | An sf geometry or a boundary box vector of the format | ||||||||||||||||||||||||||||||
poly | An sf geometry. Used as a geometric filter to includeonly those geometries that relate to | ||||||||||||||||||||||||||||||
predicate | A spatial predicate that is used to relate the outputgeometries with the object specified in | ||||||||||||||||||||||||||||||
filter | A character string containing a valid CQL or XML filter. Thisstring is appended to the query constructed through | ||||||||||||||||||||||||||||||
epsg | An EPSG code specifying a coordinate reference system of theoutput. If you're unsure what this means, try running | ||||||||||||||||||||||||||||||
properties | Vector of columns to include in the output. | ||||||||||||||||||||||||||||||
max | Maximum number of results to return. |
Value
An sf dataframe with multipolygon geometries and the followingcolumns:
debkgid: Identifier in the digital landscape model DLM250nnid: National name identifiername: Name of the geographical objectars: Territorial code (Amtlicher Regionalschlüssel).The ARS is stuctured hierarchically as follows:Position 1-2: Federal state
Position 3: Government region
Position 4-5: District
Position 6-9: Administrative association
Position 10-12: Municipality
oba: Name of the ATKIS object typekfz: Vehicle registration area code, comma-separated in case of multiple codesgeola: Geographical longitudegeobr: Geographical latitudegkre: Gauß-Krüger eastinggkho: Gauß-Krüger northingutmre: UTM eastingutmho: UTM northing
See Also
Other non-administrative regions:bkg_authorities(),bkg_grid,bkg_ror()
Examples
library(ggplot2)kfz <- bkg_kfz(ars %LIKE% "053%")ggplot(kfz) + geom_sf(fill = NA) + geom_sf_text(aes(label = kfz)) + theme_void()Kilometrage
Description
Get kilometrages of German federal motorways. Kilometrages are markersfor each kilometer of a highway. They can be used to createlinear referencing systems (LRS).
Usage
bkg_kilometrage( ..., bbox = NULL, poly = NULL, predicate = "intersects", filter = NULL, epsg = 3035, properties = NULL, max = NULL)Arguments
... | Used to construct CQL filters. Dot arguments accept an R-likesyntax that is converted to CQL queries internally. These queries basicallyconsist of a property name on the left, an aribtrary vector on the right,and an operator that links both sides. If multiple queries are provided,they will be chained with
To construct more complex queries, you can use the | ||||||||||||||||||||||||||||||
bbox | An sf geometry or a boundary box vector of the format | ||||||||||||||||||||||||||||||
poly | An sf geometry. Used as a geometric filter to includeonly those geometries that relate to | ||||||||||||||||||||||||||||||
predicate | A spatial predicate that is used to relate the outputgeometries with the object specified in | ||||||||||||||||||||||||||||||
filter | A character string containing a valid CQL or XML filter. Thisstring is appended to the query constructed through | ||||||||||||||||||||||||||||||
epsg | An EPSG code specifying a coordinate reference system of theoutput. If you're unsure what this means, try running | ||||||||||||||||||||||||||||||
properties | Vector of columns to include in the output. | ||||||||||||||||||||||||||||||
max | Maximum number of results to return. |
Value
A dataframe containing the following columns:
name: Geographical name of the POIgemeinde: Municipality nameverwaltung: Administrative association namekreis: District nameregierungs: Government region namebundesland: Federal state namebez: Label of the federal motorwaykilometer: Kilometrage of the motorwayrichtung: Direction of the kilometrage
Query language
By default, WFS requests use CQL (Contextual Query Language) queries forsimplicity. CQL queries only work together with GET requests. This meansthat when the URL is longer than 2048 characters, they fail.While POST requests are much more flexible and able to accommodate longqueries, XML is really a pain to work with and I'm not confident in myapproach to construct XML queries. You can control whether to send GET orPOST requests by settingoptions(ffm_query_language = "XML")oroptions(ffm_query_language = "CQL").
See Also
TherLFT package for linear referencing
Other points of interest:bkg_airports(),bkg_crossings(),bkg_heliports(),bkg_seaports(),bkg_stations(),bkg_trauma_centers()
Examples
# Get the kilometrage of the A2 motorwaya2 <- bkg_kilometrage(bez == "A2")plot(a2["kilometer"], pch = 16)NUTS regions
Description
Retrieve polygons of NUTS regions.
This function interfaces thenuts* products of the BKG.
Usage
bkg_nuts( level = c("1", "2", "3"), scale = c("250", "1000", "2500", "5000"), key_date = c("0101", "1231"), year = "latest", timeout = 120, update_cache = FALSE)Arguments
level | NUTS level to download. Can be |
scale | Scale of the geometries. Can be |
key_date | For |
year | Version year of the dataset. You can use |
timeout | Timeout value for the data download passed to |
update_cache | By default, downloaded files are cached in the |
Value
An sf dataframe with multipolygon geometries and the followingcolumns:
GF: Integer representing the geofactor; whether an area is"structured" or not. Land is structured if it is part of a state or otheradministrative unit but is not further divided into administrative units.Can be one of1: Unstructured, waterbody
2: Structured, waterbody
3: Unstructured, land
4: Structured, land
NUTS_LEVEL: NUTS level. Can be one of1: NUTS-1; federal states
2: NUTS-2; inconsistent, somewhere between government regions andfederal states
3: NUTS-3; districts
NUTS_CODE: Hierarchical key of the NUTS region. Can have a different numberof characters depending on the NUTS level:NUTS-1: three digits
NUTS-2: four digits
NUTS-3: five digits
NUTS_NAME: Geographical name of the NUTS region
Note
This function does not query a WFS so you are only able to downloadentire datasets without the ability to filter beforehand.
See Also
bkg_admin for retrieving German administrative areas
Datasets:admin_data,nuts_data
Examples
# Download NUTS state data from 2020bkg_nuts(scale = "5000", year = 2020)# Download the latest NUTS district databkg_nuts(level = "3")Quasigeoid
Description
Retrieves the "German Combined Quasigeoid", the official height referencesurface of the German land survey above the reference ellipsoid (GRS80).
A quasigeoid is an approximation of the geoid surface used to define normalheights above the earth's surface that is based on more practical assumptionsthan a true geoid. It defines heights in meters that can be more meaningfulthan ellipsoidal heights in many applications like surveying, hydrologicalmodeling, engineering, or spatial analysis.
This function interfaces thequasigeoid product of the BKG.
Usage
bkg_quasigeoid( year = "latest", region = c("all", "coast", "no", "nw", "s", "w"), timeout = 120, update_cache = FALSE)Arguments
year | Version year of the dataset. You can use |
region | Subterritory of Germany. |
timeout | Timeout value for the data download passed to |
update_cache | By default, downloaded files are cached in the |
Value
ASpatRaster containing normal heightsfor the specifiedregion. The data comes in EPSG:4258 and aresolution of 30" x 45" (approximately 0.9 x 0.9 km).
Examples
library(terra)qgeoid <- bkg_quasigeoid(region = "no")terra::plot(qgeoid)Non-administrative regions
Description
Retrieve areal data related to what the BKG calls non-administrativeregions. This includes:
bkg_ror: Raumordnungsregionen (Spatial planning regions)bkg_rg: Reisegebiete (Travel areas)bkg_amr: Arbeitsmarktregionen (Labor market regions)bkg_bkr: Braunkohlereviere (Lignite regions)bkg_krg: Kreisregionen (District regions)bkg_mbe: BBSR Mittelbereiche (BBSR middle areas)bkg_ggr: Großstadtregionen (City regions)bkg_kmr: Metropolregionen (Metropolitan regions)bkg_mkro: Verdichtungsräume (Conurbations)
These functions interface thege* product of the BKG.
Usage
bkg_ror( scale = c("250", "1000", "2500", "5000"), year = "latest", timeout = 120, update_cache = FALSE)bkg_rg( scale = c("250", "1000", "2500", "5000"), year = "latest", timeout = 120, update_cache = FALSE)bkg_amr( scale = c("250", "1000", "2500", "5000"), year = "latest", timeout = 120, update_cache = FALSE)bkg_bkr( scale = c("250", "1000", "2500", "5000"), year = "latest", timeout = 120, update_cache = FALSE)bkg_krg( scale = c("250", "1000", "2500", "5000"), year = "latest", timeout = 120, update_cache = FALSE)bkg_mbe( scale = c("250", "1000", "2500", "5000"), year = "latest", timeout = 120, update_cache = FALSE)bkg_ggr( scale = c("250", "1000", "2500", "5000"), year = "latest", timeout = 120, update_cache = FALSE)bkg_kmr( scale = c("250", "1000", "2500", "5000"), year = "latest", timeout = 120, update_cache = FALSE)bkg_mkro( scale = c("250", "1000", "2500", "5000"), year = "latest", timeout = 120, update_cache = FALSE)Arguments
scale | Scale of the geometries. Can be |
year | Version year of the dataset. You can use |
timeout | Timeout value for the data download passed to |
update_cache | By default, downloaded files are cached in the |
Value
An sf tibble with multipolygon geometries and two features,a regional identifier and the region endonyms.
See Also
Other non-administrative regions:bkg_authorities(),bkg_grid,bkg_kfz()
Seaports
Description
Retrieve seaports to the North and Baltic Sea in Northern Germany.
Usage
bkg_seaports( ..., bbox = NULL, poly = NULL, predicate = "intersects", filter = NULL, epsg = 3035, properties = NULL, max = NULL)Arguments
... | Used to construct CQL filters. Dot arguments accept an R-likesyntax that is converted to CQL queries internally. These queries basicallyconsist of a property name on the left, an aribtrary vector on the right,and an operator that links both sides. If multiple queries are provided,they will be chained with
To construct more complex queries, you can use the | ||||||||||||||||||||||||||||||
bbox | An sf geometry or a boundary box vector of the format | ||||||||||||||||||||||||||||||
poly | An sf geometry. Used as a geometric filter to includeonly those geometries that relate to | ||||||||||||||||||||||||||||||
predicate | A spatial predicate that is used to relate the outputgeometries with the object specified in | ||||||||||||||||||||||||||||||
filter | A character string containing a valid CQL or XML filter. Thisstring is appended to the query constructed through | ||||||||||||||||||||||||||||||
epsg | An EPSG code specifying a coordinate reference system of theoutput. If you're unsure what this means, try running | ||||||||||||||||||||||||||||||
properties | Vector of columns to include in the output. | ||||||||||||||||||||||||||||||
max | Maximum number of results to return. |
Value
A dataframe containing the following columns:
name: Geographical name of the POIgemeinde: Municipality nameverwaltung: Administrative association namekreis: District nameregierungs: Government region namebundesland: Federal state namepoi_id: Unique primary key of a point of interestbetreiber: Operator of the seaporthomepage: Homepage of the operatortyp: Type of seaport. Can be "Seehafen" (seaport) or"See- und Binnenhafen" (sea and inland port)art: Type of seaport by freight. Can be:Güter: Goods
Güter und Passagiere: Goods and passengers
Passagiere: Passengers
quelle: Source of the information. Can be:BSH: Federal Maritime and Hydrographic Agency
MarWiLo: Maritime Wirtschaft & Logistik
ZDS-Seehäfen: Zentralverband der deutschen Seehafenbetriebe
Query language
By default, WFS requests use CQL (Contextual Query Language) queries forsimplicity. CQL queries only work together with GET requests. This meansthat when the URL is longer than 2048 characters, they fail.While POST requests are much more flexible and able to accommodate longqueries, XML is really a pain to work with and I'm not confident in myapproach to construct XML queries. You can control whether to send GET orPOST requests by settingoptions(ffm_query_language = "XML")oroptions(ffm_query_language = "CQL").
See Also
Other points of interest:bkg_airports(),bkg_crossings(),bkg_heliports(),bkg_kilometrage(),bkg_stations(),bkg_trauma_centers()
Examples
# Get only seaports that co-function as inland portsports <- bkg_seaports(typ == "See- und Binnenhafen")germany <- bkg_admin(level = "sta", scale = "5000", gf == 9)plot(germany$geometry)plot(ports$geometry, add = TRUE)Stations and stops
Description
Retrieve data on public transport stations and stops in Germany. Stationsand stops are hierarchical. This means that stations represent thestructural facilities as hierarchically superior objects and stops arehierarchically inferiors parts of a station (e.g., a single platformat a bus stop).
Usage
bkg_stations( ..., bbox = NULL, poly = NULL, predicate = "intersects", filter = NULL, epsg = 3035, properties = NULL, max = NULL)Arguments
... | Used to construct CQL filters. Dot arguments accept an R-likesyntax that is converted to CQL queries internally. These queries basicallyconsist of a property name on the left, an aribtrary vector on the right,and an operator that links both sides. If multiple queries are provided,they will be chained with
To construct more complex queries, you can use the | ||||||||||||||||||||||||||||||
bbox | An sf geometry or a boundary box vector of the format | ||||||||||||||||||||||||||||||
poly | An sf geometry. Used as a geometric filter to includeonly those geometries that relate to | ||||||||||||||||||||||||||||||
predicate | A spatial predicate that is used to relate the outputgeometries with the object specified in | ||||||||||||||||||||||||||||||
filter | A character string containing a valid CQL or XML filter. Thisstring is appended to the query constructed through | ||||||||||||||||||||||||||||||
epsg | An EPSG code specifying a coordinate reference system of theoutput. If you're unsure what this means, try running | ||||||||||||||||||||||||||||||
properties | Vector of columns to include in the output. | ||||||||||||||||||||||||||||||
max | Maximum number of results to return. |
Value
A dataframe with the following columns:
name: Geographical name of the POIgemeinde: Municipality nameverwaltung: Administrative association namekreis: District nameregierungs: Government region namebundesland: Federal state namestop_id: Identifier of the station or stopparent_st: Identifier of the parent station if applicableverkehrsm: Vehicle used at the station, comma-separatedand sorted alphabeticallyart: Hierarchical position of a station. Can be:Station: A physical structure and hierarchically superior
Haltestelle: Part of a structure and hierarchically inferior
tag_f_awo: Mean departures per day in a work weektag_f_wo: Mean departures per day in a full week
Query language
By default, WFS requests use CQL (Contextual Query Language) queries forsimplicity. CQL queries only work together with GET requests. This meansthat when the URL is longer than 2048 characters, they fail.While POST requests are much more flexible and able to accommodate longqueries, XML is really a pain to work with and I'm not confident in myapproach to construct XML queries. You can control whether to send GET orPOST requests by settingoptions(ffm_query_language = "XML")oroptions(ffm_query_language = "CQL").
See Also
Other points of interest:bkg_airports(),bkg_crossings(),bkg_heliports(),bkg_kilometrage(),bkg_seaports(),bkg_trauma_centers()
Examples
# Get all long-distance train stationsbkg_stations(verkehrsm %LIKE% "%Fernzug%", art == "Station")# Get all platforms of long-distance train stationsbkg_stations(verkehrsm %LIKE% "%Fernzug%", art == "Haltestelle")# Get all stops with high trafficbkg_stations(tag_f_awo > 1000, art == "Station")# Get all bus stops with low trafficbkg_stations(tag_f_awo < 1, verkehrsm %LIKE% "%Bus%", art == "Station")Trauma centers
Description
Retrieve data on trauma centers in Germany. A trauma center is a hospitalcertified by the German Society for Trauma Surgery (DGU) that is able toprovide maximum care for heavily injured people. Trauma centers areorganized in a hierarchical regional network that ranges from local totransregional centers.
Usage
bkg_trauma_centers( ..., bbox = NULL, poly = NULL, predicate = "intersects", filter = NULL, epsg = 3035, properties = NULL, max = NULL)Arguments
... | Used to construct CQL filters. Dot arguments accept an R-likesyntax that is converted to CQL queries internally. These queries basicallyconsist of a property name on the left, an aribtrary vector on the right,and an operator that links both sides. If multiple queries are provided,they will be chained with
To construct more complex queries, you can use the | ||||||||||||||||||||||||||||||
bbox | An sf geometry or a boundary box vector of the format | ||||||||||||||||||||||||||||||
poly | An sf geometry. Used as a geometric filter to includeonly those geometries that relate to | ||||||||||||||||||||||||||||||
predicate | A spatial predicate that is used to relate the outputgeometries with the object specified in | ||||||||||||||||||||||||||||||
filter | A character string containing a valid CQL or XML filter. Thisstring is appended to the query constructed through | ||||||||||||||||||||||||||||||
epsg | An EPSG code specifying a coordinate reference system of theoutput. If you're unsure what this means, try running | ||||||||||||||||||||||||||||||
properties | Vector of columns to include in the output. | ||||||||||||||||||||||||||||||
max | Maximum number of results to return. |
Value
A dataframe containing the following columns:
name: Geographical name of the POIgemeinde: Municipality nameverwaltung: Administrative association namekreis: District nameregierungs: Government region namebundesland: Federal state namepoi_id: Unique primary key of a point of interesttz_nummer: Unique primary key of the trauma centerstrasse: Streethn: House numberplz: Zip codeort: Place namenetwerk: Name of the regional trauma center networkabteilung: Name of the medical departmenttyp: Type of trauma center. Can be:LTZ: local trauma center
RTZ: regional trauma center
ÜTZ: transregional trauma center
Query language
By default, WFS requests use CQL (Contextual Query Language) queries forsimplicity. CQL queries only work together with GET requests. This meansthat when the URL is longer than 2048 characters, they fail.While POST requests are much more flexible and able to accommodate longqueries, XML is really a pain to work with and I'm not confident in myapproach to construct XML queries. You can control whether to send GET orPOST requests by settingoptions(ffm_query_language = "XML")oroptions(ffm_query_language = "CQL").
See Also
Other points of interest:bkg_airports(),bkg_crossings(),bkg_heliports(),bkg_kilometrage(),bkg_seaports(),bkg_stations()
Examples
# Get only trauma centers specializing on orthopedicsbkg_trauma_centers(abteilung %LIKE% "%orthopäd%")# Get only local trauma centersbkg_trauma_centers(typ == "LTZ")if (requireNamespace("ggplot2")) { library(ggplot2) centers <- bkg_trauma_centers() ggplot() + geom_sf( data = centers[centers$typ %in% "LTZ",], size = 1, color = "lightblue1" ) + geom_sf( data = centers[centers$typ %in% "RTZ",], size = 2, color = "lightblue3" ) + geom_sf( data = centers[centers$typ %in% "ÜTZ",], size = 3, color = "lightblue4" ) + theme_void()}BKG WCS
Description
Low-level interface to BKG-style web coverage services (WCS). This functionis used in all high-level functions offfm that depend on a WCS,e.g.,bkg_dem.
Usage
bkg_wcs( coverage_id, endpoint = coverage_id, version = "2.0.1", method = NULL, format = "image/tiff;application=geotiff", epsg = 3035, interpolation = NULL, ...)Arguments
coverage_id | Coverage ID. When in doubt, inspect the |
endpoint | Endpoint to interface. Note that |
version | Service version of the WCS. Defaults to |
method | HTTP method to use for the request. If |
format | Content type of the output. This value heavily dependsthe endpoint queried. Defaults to |
epsg | Numeric value giving the EPSG identifier of the coordinatereference system (CRS). The EPSG code is automatically formatted in aOGC-compliant manner. Note that not all EPSG codes are supported. Inspectthe |
interpolation | Method used to interpolate the coverage raster.Allowed methods depend on the capabilities of the WCS. |
... | Further parameters passed to the WFS query. In case of |
Value
Examples
# Boundaries can be provided using two subset argumentsbkg_wcs( "dgm200_inspire__EL.GridCoverage", endpoint = "dgm200_inspire", subset = "E(548282,552280)", subset = "N(5800943,5804942)")BKG WFS
Description
Low-level interface to BKG-style web feature services (WFS). This functionis used in all high-level functions offfm that depend on a WFS,e.g.,bkg_admin.
bkg_feature_types lists all available feature types for a givenendpoint.
Usage
bkg_wfs( type_name, endpoint = type_name, version = "2.0.0", method = NULL, format = "application/json", layer = NULL, epsg = 3035, properties = NULL, filter = NULL, server = sgx_base(), ...)bkg_feature_types(endpoint, server = sgx_base())Arguments
type_name | Feature type of the WFS to retrieve. You can use |
endpoint | Endpoint to interface. Note that |
version | Service version of the WFS. Usually 2.0.0, but some servicesstill use 1.0.0 or 1.1.0. |
method | HTTP method to use for the request. If |
format | Content type of the output. This value heavily dependsthe endpoint queried. Most services allow |
layer | If |
epsg | Numeric value giving the EPSG identifier of the coordinatereference system (CRS). The EPSG code is automatically formatted in aOGC-compliant manner. Note that not all EPSG codes are supported. Inspectthe |
properties | Names of columns to include in the output. Defaults to |
filter | A WFS filter query (CQL or XML) created by |
server | WFS server domain to use. Defaults to the SGX spatial datacenter of the BKG. |
... | Further parameters passed to the WFS query. In case of |
Value
An sf tibble
See Also
bkg_wcs for a low-level WCS interface
wfs_filter for filter constructors
Examples
bkg_feature_types("vg5000_0101")bkg_wfs( "vg5000_lan", endpoint = "vg5000_0101", count = 5, properties = "gen", epsg = 4326)[-1]# Filters are created using `wfs_filter()`bkg_wfs( "vg5000_krs", endpoint = "vg5000_0101", properties = "gen", filter = wfs_filter(sn_l == 10))[-1]German NUTSMULTIPOLYGONs
Description
Threesf dataframes containing all geometries ofGerman NUTS1, NUTS2, and NUTS3 regions, respectively. The reference yearis 2023.
These datasets can be very useful for quickly retrieving pre-loadedboundaries without download.
Usage
bkg_nuts1bkg_nuts2bkg_nuts3Format
For the dataframe format, seebkg_nuts.
An object of classsf (inherits fromtbl_df,tbl,data.frame) with 38 rows and 7 columns.
An object of classsf (inherits fromtbl_df,tbl,data.frame) with 400 rows and 7 columns.
Source
© BKG (2025) dl-de/by-2-0, data sources:https://sgx.geodatenzentrum.de/web_public/gdz/datenquellen/datenquellen_vg_nuts.pdf
See Also
Other datasets:admin_data
Examples
bkg_nuts1WFS filters
Description
Utility functions to construct XML or CQL queries. These functions are thebackend of thefilter argument in the filter capabilities of allffm functions that interact with a WFS (e.g.,bkg_admin,bkg_clc orbkb_geonames).
Usage
wfs_filter( ..., filter = NULL, bbox = NULL, poly = NULL, predicate = "intersects", geom_property = "geom", default_crs = 25832, lang = NULL)Arguments
... | Used to construct CQL filters. Dot arguments accept an R-likesyntax that is converted to CQL queries internally. These queries basicallyconsist of a property name on the left, an aribtrary vector on the right,and an operator that links both sides. If multiple queries are provided,they will be chained with
To construct more complex queries, you can use the | ||||||||||||||||||||||||||||||
filter | A character string containing a valid CQL or XML filter. Thisstring is appended to the query constructed through | ||||||||||||||||||||||||||||||
bbox | An sf geometry or a boundary box vector of the format | ||||||||||||||||||||||||||||||
poly | An sf geometry. Used as a geometric filter to includeonly those geometries that relate to | ||||||||||||||||||||||||||||||
predicate | A spatial predicate that is used to relate the outputgeometries with the object specified in | ||||||||||||||||||||||||||||||
geom_property | Name of the geometry property included in the WFS.In most cases, this is | ||||||||||||||||||||||||||||||
default_crs | A WFS defines a default CRS in which coordinates forspatial filtering have to be provided. For BKG services, this is usuallyEPSG:25832. All sf objects provided through | ||||||||||||||||||||||||||||||
lang | Query language to use for constructing the query. One of |
Value
A CQL query or an XML query depending on thelang argument.
Examples
# CQL and XML support mostly the same thingswfs_filter(ags %LIKE% "05%", lang = "cql")wfs_filter(ags %LIKE% "05%", lang = "xml")bbox <- c(xmin = 5, ymin = 50, xmax = 7, ymax = 52)wfs_filter(bbox = bbox, lang = "cql")wfs_filter(bbox = bbox, lang = "xml")# Using `filter`, more complex queries can be builtwfs_filter(ars %LIKE% "%0", filter = "regierungs NOT IS NULL")wfs_filter( filter = "<fes:Not> <fes:PropertyIsNull> <fes:ValueReference>aussprache</fes:ValueReference> </fes:PropertyIsNull> </fes:Not>", lang = "xml")