Movatterモバイル変換


[0]ホーム

URL:


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 LiethORCID iD [aut, cre, cph]
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_germany

Format

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

bkg_admin

Other datasets:nuts_data

Examples

bkg_krs

Administrative areas

Description

Retrieve polygon geometries of administrative areas in Germany. Alladministrative levels are supported at different spatial resolutions.

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 withAND. The following operators and theirrespective equivalents in CQL and XML are supported:

RCQLXML
===PropertyIsEqualTo
!=<>PropertyIsNotEqualTo
<<PropertyIsLessThan
>>PropertyIsGreaterThan
>=>=PropertyIsGreaterThanOrEqualTo
<=<=PropertyIsLessThanOrEqualTo
%LIKE%LIKEPropertyIsLike
%ILIKE%ILIKE
%in%INPropertyIsEqualTo andOr

To construct more complex queries, you can use thefilter argumentto pass CQL queries directly. Also note that you can switch betweenCQL and XML queries usingoptions(ffm_query_language = "xml").See alsowfs_filter.

level

Administrative level to download. Must be one of"sta" (Germany),"lan" (federal states),"rbz"(governmental districts),"krs" (districts),"vwg"(administrative associations),"gem" (municipalities),"li" (boundary lines), or"pk" (municipality centroids).Defaults to districts.

scale

Scale of the geometries. Can be"250"(1:250,000),"1000" (1:1,000,000),"2500" (1:2,500,000)or"5000" (1:5,000,000). If"250", population data is includedin the output. Defaults to"250".

key_date

Forresolution %in% c("250", "5000"), specifies the keydate from which to download administrative data. Can be either"0101"(January 1) or"1231" (December 31). The latter is able togeoreference statistical data while the first integrates changes madein the new year. If"1231", population data is attached, otherwisenot. Note that population data is not available at all scales (usually250 and 1000). Defaults to "0101".

bbox

An sf geometry or a boundary box vector of the formatc(xmin, ymin, xmax, ymax). Used as a geometric filter to includeonly those geometries that relate tobbox according to the predicatespecified inpredicate. If an sf geometry is provided, coordinatesare automatically transformed to ESPG:25832 (the default CRS), otherwisethey are expected to be in EPSG:25832.

poly

An sf geometry. Used as a geometric filter to includeonly those geometries that relate topoly according to the predicatespecified inpredicate. Coordinates are automatically transformed toESPG:25832 (the default CRS).

predicate

A spatial predicate that is used to relate the outputgeometries with the object specified inbbox orpoly. Forexample, ifpredicate = "within", andbbox is specified,returns only those geometries that lie withinbbox. Can be one of"equals","disjoint","intersects","touches","crosses","within","contains","overlaps","relate","dwithin", or"beyond". Defaults to"intersects".

filter

A character string containing a valid CQL or XML filter. Thisstring is appended to the query constructed through.... Use thisargument to construct more complex filters. Defaults toNULL.

epsg

An EPSG code specifying a coordinate reference system of theoutput. If you're unsure what this means, try runningsf::st_crs(...)$epsg on a spatial object that you are working with.Defaults to 3035.

properties

Vector of columns to include in the output.

max

Maximum number of results to return.

year

Version year of the dataset. You can uselatest toretrieve the latest dataset version available on the BKG's geodata center.Older versions can be browsed using thearchive.

timeout

Timeout value for the data download passed toreq_timeout. Adjust this if your internet connection isslow or you are downloading larger datasets.

update_cache

By default, downloaded files are cached in thetempdir() directory of R. When downloading the same data again,the data is not downloaded but instead taken from the cache. Sometimesthis can be not the desired behavior. If you want to overwrite the cache,passTRUE. Defaults toFALSE, i.e. always adopt the cacheif possible.

layer

Thevg25 product used inbkg_admin_highrescontains a couple of metadata files. You can set a layer name to read thesefiles, otherwise the main file is read.

Value

An sf dataframe with multipolygon geometries and different columnsdepending on the geometry type.Areal geometries generally have the following columns:

Boundary geometries ("li") can have additional columns:

Point geometries ("pk") have the following additional columns:

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

vg250-ew documentation

vg250-ew MIS record

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

Forresolution %in% c("250", "5000"), specifies the keydate from which to download administrative data. Can be either"0101"(January 1) or"1231" (December 31). The latter is able togeoreference statistical data while the first integrates changes madein the new year. If"1231", population data is attached, otherwisenot. Note that population data is not available at all scales (usually250 and 1000). Defaults to "0101".

year

Version year of the dataset. You can uselatest toretrieve the latest dataset version available on the BKG's geodata center.Older versions can be browsed using thearchive.

timeout

Timeout value for the data download passed toreq_timeout. Adjust this if your internet connection isslow or you are downloading larger datasets.

update_cache

By default, downloaded files are cached in thetempdir() directory of R. When downloading the same data again,the data is not downloaded but instead taken from the cache. Sometimesthis can be not the desired behavior. If you want to overwrite the cache,passTRUE. Defaults toFALSE, i.e. always adopt the cacheif possible.

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 withAND. The following operators and theirrespective equivalents in CQL and XML are supported:

RCQLXML
===PropertyIsEqualTo
!=<>PropertyIsNotEqualTo
<<PropertyIsLessThan
>>PropertyIsGreaterThan
>=>=PropertyIsGreaterThanOrEqualTo
<=<=PropertyIsLessThanOrEqualTo
%LIKE%LIKEPropertyIsLike
%ILIKE%ILIKE
%in%INPropertyIsEqualTo andOr

To construct more complex queries, you can use thefilter argumentto pass CQL queries directly. Also note that you can switch betweenCQL and XML queries usingoptions(ffm_query_language = "xml").See alsowfs_filter.

filter

A character string containing a valid CQL or XML filter. Thisstring is appended to the query constructed through.... Use thisargument to construct more complex filters. Defaults toNULL.

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 withAND. The following operators and theirrespective equivalents in CQL and XML are supported:

RCQLXML
===PropertyIsEqualTo
!=<>PropertyIsNotEqualTo
<<PropertyIsLessThan
>>PropertyIsGreaterThan
>=>=PropertyIsGreaterThanOrEqualTo
<=<=PropertyIsLessThanOrEqualTo
%LIKE%LIKEPropertyIsLike
%ILIKE%ILIKE
%in%INPropertyIsEqualTo andOr

To construct more complex queries, you can use thefilter argumentto pass CQL queries directly. Also note that you can switch betweenCQL and XML queries usingoptions(ffm_query_language = "xml").See alsowfs_filter.

bbox

An sf geometry or a boundary box vector of the formatc(xmin, ymin, xmax, ymax). Used as a geometric filter to includeonly those geometries that relate tobbox according to the predicatespecified inpredicate. If an sf geometry is provided, coordinatesare automatically transformed to ESPG:25832 (the default CRS), otherwisethey are expected to be in EPSG:25832.

poly

An sf geometry. Used as a geometric filter to includeonly those geometries that relate topoly according to the predicatespecified inpredicate. Coordinates are automatically transformed toESPG:25832 (the default CRS).

predicate

A spatial predicate that is used to relate the outputgeometries with the object specified inbbox orpoly. Forexample, ifpredicate = "within", andbbox is specified,returns only those geometries that lie withinbbox. Can be one of"equals","disjoint","intersects","touches","crosses","within","contains","overlaps","relate","dwithin", or"beyond". Defaults to"intersects".

filter

A character string containing a valid CQL or XML filter. Thisstring is appended to the query constructed through.... Use thisargument to construct more complex filters. Defaults toNULL.

epsg

An EPSG code specifying a coordinate reference system of theoutput. If you're unsure what this means, try runningsf::st_crs(...)$epsg on a spatial object that you are working with.Defaults to 3035.

properties

Vector of columns to include in the output.

max

Maximum number of results to return.

Value

A dataframe containing the following columns:

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

wfs_poi_open documentation

wfs_poi_open MIS record

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 withAND. The following operators and theirrespective equivalents in CQL and XML are supported:

RCQLXML
===PropertyIsEqualTo
!=<>PropertyIsNotEqualTo
<<PropertyIsLessThan
>>PropertyIsGreaterThan
>=>=PropertyIsGreaterThanOrEqualTo
<=<=PropertyIsLessThanOrEqualTo
%LIKE%LIKEPropertyIsLike
%ILIKE%ILIKE
%in%INPropertyIsEqualTo andOr

To construct more complex queries, you can use thefilter argumentto pass CQL queries directly. Also note that you can switch betweenCQL and XML queries usingoptions(ffm_query_language = "xml").See alsowfs_filter.

bbox

An sf geometry or a boundary box vector of the formatc(xmin, ymin, xmax, ymax). Used as a geometric filter to includeonly those geometries that relate tobbox according to the predicatespecified inpredicate. If an sf geometry is provided, coordinatesare automatically transformed to ESPG:25832 (the default CRS), otherwisethey are expected to be in EPSG:25832.

poly

An sf geometry. Used as a geometric filter to includeonly those geometries that relate topoly according to the predicatespecified inpredicate. Coordinates are automatically transformed toESPG:25832 (the default CRS).

predicate

A spatial predicate that is used to relate the outputgeometries with the object specified inbbox orpoly. Forexample, ifpredicate = "within", andbbox is specified,returns only those geometries that lie withinbbox. Can be one of"equals","disjoint","intersects","touches","crosses","within","contains","overlaps","relate","dwithin", or"beyond". Defaults to"intersects".

filter

A character string containing a valid CQL or XML filter. Thisstring is appended to the query constructed through.... Use thisargument to construct more complex filters. Defaults toNULL.

epsg

An EPSG code specifying a coordinate reference system of theoutput. If you're unsure what this means, try runningsf::st_crs(...)$epsg on a spatial object that you are working with.Defaults to 3035.

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"employment_agencies","employment_offices","job_centers","directorates","local_courts","regional_courts", or"higher_regional_courts".

...

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 withAND. The following operators and theirrespective equivalents in CQL and XML are supported:

RCQLXML
===PropertyIsEqualTo
!=<>PropertyIsNotEqualTo
<<PropertyIsLessThan
>>PropertyIsGreaterThan
>=>=PropertyIsGreaterThanOrEqualTo
<=<=PropertyIsLessThanOrEqualTo
%LIKE%LIKEPropertyIsLike
%ILIKE%ILIKE
%in%INPropertyIsEqualTo andOr

To construct more complex queries, you can use thefilter argumentto pass CQL queries directly. Also note that you can switch betweenCQL and XML queries usingoptions(ffm_query_language = "xml").See alsowfs_filter.

bbox

An sf geometry or a boundary box vector of the formatc(xmin, ymin, xmax, ymax). Used as a geometric filter to includeonly those geometries that relate tobbox according to the predicatespecified inpredicate. If an sf geometry is provided, coordinatesare automatically transformed to ESPG:25832 (the default CRS), otherwisethey are expected to be in EPSG:25832.

poly

An sf geometry. Used as a geometric filter to includeonly those geometries that relate topoly according to the predicatespecified inpredicate. Coordinates are automatically transformed toESPG:25832 (the default CRS).

predicate

A spatial predicate that is used to relate the outputgeometries with the object specified inbbox orpoly. Forexample, ifpredicate = "within", andbbox is specified,returns only those geometries that lie withinbbox. Can be one of"equals","disjoint","intersects","touches","crosses","within","contains","overlaps","relate","dwithin", or"beyond". Defaults to"intersects".

filter

A character string containing a valid CQL or XML filter. Thisstring is appended to the query constructed through.... Use thisargument to construct more complex filters. Defaults toNULL.

epsg

An EPSG code specifying a coordinate reference system of theoutput. If you're unsure what this means, try runningsf::st_crs(...)$epsg on a spatial object that you are working with.Defaults to 3035.

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:

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

bzb-open documentation

bzb-open MIS record

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 withAND. The following operators and theirrespective equivalents in CQL and XML are supported:

RCQLXML
===PropertyIsEqualTo
!=<>PropertyIsNotEqualTo
<<PropertyIsLessThan
>>PropertyIsGreaterThan
>=>=PropertyIsGreaterThanOrEqualTo
<=<=PropertyIsLessThanOrEqualTo
%LIKE%LIKEPropertyIsLike
%ILIKE%ILIKE
%in%INPropertyIsEqualTo andOr

To construct more complex queries, you can use thefilter argumentto pass CQL queries directly. Also note that you can switch betweenCQL and XML queries usingoptions(ffm_query_language = "xml").See alsowfs_filter.

year

Version year of the dataset. You can uselatest toretrieve the latest dataset version available on the BKG's geodata center.Older versions can be browsed using thearchive.

bbox

An sf geometry or a boundary box vector of the formatc(xmin, ymin, xmax, ymax). Used as a geometric filter to includeonly those geometries that relate tobbox according to the predicatespecified inpredicate. If an sf geometry is provided, coordinatesare automatically transformed to ESPG:25832 (the default CRS), otherwisethey are expected to be in EPSG:25832.

poly

An sf geometry. Used as a geometric filter to includeonly those geometries that relate topoly according to the predicatespecified inpredicate. Coordinates are automatically transformed toESPG:25832 (the default CRS).

predicate

A spatial predicate that is used to relate the outputgeometries with the object specified inbbox orpoly. Forexample, ifpredicate = "within", andbbox is specified,returns only those geometries that lie withinbbox. Can be one of"equals","disjoint","intersects","touches","crosses","within","contains","overlaps","relate","dwithin", or"beyond". Defaults to"intersects".

filter

A character string containing a valid CQL or XML filter. Thisstring is appended to the query constructed through.... Use thisargument to construct more complex filters. Defaults toNULL.

epsg

An EPSG code specifying a coordinate reference system of theoutput. If you're unsure what this means, try runningsf::st_crs(...)$epsg on a spatial object that you are working with.Defaults to 3035.

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:

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

wfs_clc5_2018 documentation

wfs_clc5_2018 MIS record

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 withAND. The following operators and theirrespective equivalents in CQL and XML are supported:

RCQLXML
===PropertyIsEqualTo
!=<>PropertyIsNotEqualTo
<<PropertyIsLessThan
>>PropertyIsGreaterThan
>=>=PropertyIsGreaterThanOrEqualTo
<=<=PropertyIsLessThanOrEqualTo
%LIKE%LIKEPropertyIsLike
%ILIKE%ILIKE
%in%INPropertyIsEqualTo andOr

To construct more complex queries, you can use thefilter argumentto pass CQL queries directly. Also note that you can switch betweenCQL and XML queries usingoptions(ffm_query_language = "xml").See alsowfs_filter.

bbox

An sf geometry or a boundary box vector of the formatc(xmin, ymin, xmax, ymax). Used as a geometric filter to includeonly those geometries that relate tobbox according to the predicatespecified inpredicate. If an sf geometry is provided, coordinatesare automatically transformed to ESPG:25832 (the default CRS), otherwisethey are expected to be in EPSG:25832.

poly

An sf geometry. Used as a geometric filter to includeonly those geometries that relate topoly according to the predicatespecified inpredicate. Coordinates are automatically transformed toESPG:25832 (the default CRS).

predicate

A spatial predicate that is used to relate the outputgeometries with the object specified inbbox orpoly. Forexample, ifpredicate = "within", andbbox is specified,returns only those geometries that lie withinbbox. Can be one of"equals","disjoint","intersects","touches","crosses","within","contains","overlaps","relate","dwithin", or"beyond". Defaults to"intersects".

filter

A character string containing a valid CQL or XML filter. Thisstring is appended to the query constructed through.... Use thisargument to construct more complex filters. Defaults toNULL.

epsg

An EPSG code specifying a coordinate reference system of theoutput. If you're unsure what this means, try runningsf::st_crs(...)$epsg on a spatial object that you are working with.Defaults to 3035.

properties

Vector of columns to include in the output.

max

Maximum number of results to return.

Value

A dataframe with the following columns:

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

wfs_poi_open documentation

wfs_poi_open MIS record

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 formatc(xmin, ymin, xmax, ymax). Used as a geometric filter to mask thecoverage raster. If an sf geometry is provided, coordinatesare automatically transformed to ESPG:25832 (the default CRS), otherwisethey are expected to be in EPSG:25832.

interpolation

Interpolation method to preprocess the raster.Can be"nearest-neighbor","linear", or"cubic".Does not seem to work currently - despite being listed as a capability ofthe WCS.

epsg

An EPSG code specifying a coordinate reference system of theoutput. If you're unsure what this means, try runningsf::st_crs(...)$epsg on a spatial object that you are working with.Defaults to 3035.

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 withAX_ or not. Providing an identifierdirectly is generally faster as the description needs to be matchedby requesting theGetCapabilities endpoint of the service.

Note that not all feature types are available for all shapes (see theshape argument). To see all available feature types, you can runbkg_feature_types("dlm250") orbkg_feature_types("dlm1000").

...

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 withAND. The following operators and theirrespective equivalents in CQL and XML are supported:

RCQLXML
===PropertyIsEqualTo
!=<>PropertyIsNotEqualTo
<<PropertyIsLessThan
>>PropertyIsGreaterThan
>=>=PropertyIsGreaterThanOrEqualTo
<=<=PropertyIsLessThanOrEqualTo
%LIKE%LIKEPropertyIsLike
%ILIKE%ILIKE
%in%INPropertyIsEqualTo andOr

To construct more complex queries, you can use thefilter argumentto pass CQL queries directly. Also note that you can switch betweenCQL and XML queries usingoptions(ffm_query_language = "xml").See alsowfs_filter.

shape

Geometry type of the feature type. Must be one of"point","line", or"polygon". Defaults to"point". Not allshapes are available for all feature types.

scale

Scale of the geometries. Can be"250"(1:250,000) or"1000" (1:1,000,000). Defaults to"250".

bbox

An sf geometry or a boundary box vector of the formatc(xmin, ymin, xmax, ymax). Used as a geometric filter to includeonly those geometries that relate tobbox according to the predicatespecified inpredicate. If an sf geometry is provided, coordinatesare automatically transformed to ESPG:25832 (the default CRS), otherwisethey are expected to be in EPSG:25832.

poly

An sf geometry. Used as a geometric filter to includeonly those geometries that relate topoly according to the predicatespecified inpredicate. Coordinates are automatically transformed toESPG:25832 (the default CRS).

predicate

A spatial predicate that is used to relate the outputgeometries with the object specified inbbox orpoly. Forexample, ifpredicate = "within", andbbox is specified,returns only those geometries that lie withinbbox. Can be one of"equals","disjoint","intersects","touches","crosses","within","contains","overlaps","relate","dwithin", or"beyond". Defaults to"intersects".

filter

A character string containing a valid CQL or XML filter. Thisstring is appended to the query constructed through.... Use thisargument to construct more complex filters. Defaults toNULL.

epsg

An EPSG code specifying a coordinate reference system of theoutput. If you're unsure what this means, try runningsf::st_crs(...)$epsg on a spatial object that you are working with.Defaults to 3035.

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:

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

dlm250 documentation

dlm250 MIS record

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 withAND. The following operators and theirrespective equivalents in CQL and XML are supported:

RCQLXML
===PropertyIsEqualTo
!=<>PropertyIsNotEqualTo
<<PropertyIsLessThan
>>PropertyIsGreaterThan
>=>=PropertyIsGreaterThanOrEqualTo
<=<=PropertyIsLessThanOrEqualTo
%LIKE%LIKEPropertyIsLike
%ILIKE%ILIKE
%in%INPropertyIsEqualTo andOr

To construct more complex queries, you can use thefilter argumentto pass CQL queries directly. Also note that you can switch betweenCQL and XML queries usingoptions(ffm_query_language = "xml").See alsowfs_filter.

names

IfTRUE, includes endonyms of the geographicalobjects in the output usingbkg_endonyms. Technically, this can beFALSE, because the endpoint only returns meta data on geographicalnames by default. If this argument isTRUE, the output is merged withthe endonym table requiring an additional request. Defaults toTRUE.

ags

IfTRUE, resolves AGS codes to geographical namesusingbkg_ags. Note that setting this toTRUE requiresan additional web request. Defaults toFALSE.

dlm

IfTRUE, adds the DLM identifier corresponding to thenational name identifiers (NNID) of the output usingbkg_dlm.Note that setting this toTRUE requires an additional web request.Defaults toFALSE.

status

IfTRUE, adds the date of the objects last edit tothe output. Note that setting this toTRUE requires an additionalweb request. Defaults toFALSE.

bbox

An sf geometry or a boundary box vector of the formatc(xmin, ymin, xmax, ymax). Used as a geometric filter to includeonly those geometries that relate tobbox according to the predicatespecified inpredicate. If an sf geometry is provided, coordinatesare automatically transformed to ESPG:25832 (the default CRS), otherwisethey are expected to be in EPSG:25832.

poly

An sf geometry. Used as a geometric filter to includeonly those geometries that relate topoly according to the predicatespecified inpredicate. Coordinates are automatically transformed toESPG:25832 (the default CRS).

predicate

A spatial predicate that is used to relate the outputgeometries with the object specified inbbox orpoly. Forexample, ifpredicate = "within", andbbox is specified,returns only those geometries that lie withinbbox. Can be one of"equals","disjoint","intersects","touches","crosses","within","contains","overlaps","relate","dwithin", or"beyond". Defaults to"intersects".

filter

A character string containing a valid CQL or XML filter. Thisstring is appended to the query constructed through.... Use thisargument to construct more complex filters. Defaults toNULL.

epsg

An EPSG code specifying a coordinate reference system of theoutput. If you're unsure what this means, try runningsf::st_crs(...)$epsg on a spatial object that you are working with.Defaults to 3035.

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:

Ifags = TRUE, adds the output ofbkg_ags. Ifdlm = TRUE, adds a columndlm_id containing identifiers ofbkg_dlm.

bkg_endonyms contains the following columns:

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

wfs_gnde MIS record

wfs_gnde documentation

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"2015","2017","2018" or"2019". Forbkg_grid_fast,"latest"downloads the latest version of the grid.

resolution

Cell size of the grid. Can be"100m","250m","1km","5km","10km", or"100km".

timeout

Timeout value for the data download passed toreq_timeout. Adjust this if your internet connection isslow or you are downloading larger datasets.

update_cache

By default, downloaded files are cached in thetempdir() directory of R. When downloading the same data again,the data is not downloaded but instead taken from the cache. Sometimesthis can be not the desired behavior. If you want to overwrite the cache,passTRUE. Defaults toFALSE, i.e. always adopt the cacheif possible.

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.

Sizefastfull
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:

Note thatags is only included for resolutions"100m" and"250m"

See Also

GeoGitter documentation

GeoGitter MIS record

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 withAND. The following operators and theirrespective equivalents in CQL and XML are supported:

RCQLXML
===PropertyIsEqualTo
!=<>PropertyIsNotEqualTo
<<PropertyIsLessThan
>>PropertyIsGreaterThan
>=>=PropertyIsGreaterThanOrEqualTo
<=<=PropertyIsLessThanOrEqualTo
%LIKE%LIKEPropertyIsLike
%ILIKE%ILIKE
%in%INPropertyIsEqualTo andOr

To construct more complex queries, you can use thefilter argumentto pass CQL queries directly. Also note that you can switch betweenCQL and XML queries usingoptions(ffm_query_language = "xml").See alsowfs_filter.

bbox

An sf geometry or a boundary box vector of the formatc(xmin, ymin, xmax, ymax). Used as a geometric filter to includeonly those geometries that relate tobbox according to the predicatespecified inpredicate. If an sf geometry is provided, coordinatesare automatically transformed to ESPG:25832 (the default CRS), otherwisethey are expected to be in EPSG:25832.

poly

An sf geometry. Used as a geometric filter to includeonly those geometries that relate topoly according to the predicatespecified inpredicate. Coordinates are automatically transformed toESPG:25832 (the default CRS).

predicate

A spatial predicate that is used to relate the outputgeometries with the object specified inbbox orpoly. Forexample, ifpredicate = "within", andbbox is specified,returns only those geometries that lie withinbbox. Can be one of"equals","disjoint","intersects","touches","crosses","within","contains","overlaps","relate","dwithin", or"beyond". Defaults to"intersects".

filter

A character string containing a valid CQL or XML filter. Thisstring is appended to the query constructed through.... Use thisargument to construct more complex filters. Defaults toNULL.

epsg

An EPSG code specifying a coordinate reference system of theoutput. If you're unsure what this means, try runningsf::st_crs(...)$epsg on a spatial object that you are working with.Defaults to 3035.

properties

Vector of columns to include in the output.

max

Maximum number of results to return.

Value

A dataframe with the following columns:

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

wfs_poi_open documentation

wfs_poi_open MIS record

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 withAND. The following operators and theirrespective equivalents in CQL and XML are supported:

RCQLXML
===PropertyIsEqualTo
!=<>PropertyIsNotEqualTo
<<PropertyIsLessThan
>>PropertyIsGreaterThan
>=>=PropertyIsGreaterThanOrEqualTo
<=<=PropertyIsLessThanOrEqualTo
%LIKE%LIKEPropertyIsLike
%ILIKE%ILIKE
%in%INPropertyIsEqualTo andOr

To construct more complex queries, you can use thefilter argumentto pass CQL queries directly. Also note that you can switch betweenCQL and XML queries usingoptions(ffm_query_language = "xml").See alsowfs_filter.

bbox

An sf geometry or a boundary box vector of the formatc(xmin, ymin, xmax, ymax). Used as a geometric filter to includeonly those geometries that relate tobbox according to the predicatespecified inpredicate. If an sf geometry is provided, coordinatesare automatically transformed to ESPG:25832 (the default CRS), otherwisethey are expected to be in EPSG:25832.

poly

An sf geometry. Used as a geometric filter to includeonly those geometries that relate topoly according to the predicatespecified inpredicate. Coordinates are automatically transformed toESPG:25832 (the default CRS).

predicate

A spatial predicate that is used to relate the outputgeometries with the object specified inbbox orpoly. Forexample, ifpredicate = "within", andbbox is specified,returns only those geometries that lie withinbbox. Can be one of"equals","disjoint","intersects","touches","crosses","within","contains","overlaps","relate","dwithin", or"beyond". Defaults to"intersects".

filter

A character string containing a valid CQL or XML filter. Thisstring is appended to the query constructed through.... Use thisargument to construct more complex filters. Defaults toNULL.

epsg

An EPSG code specifying a coordinate reference system of theoutput. If you're unsure what this means, try runningsf::st_crs(...)$epsg on a spatial object that you are working with.Defaults to 3035.

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:

See Also

kfz250 documentation

kfz250 MIS record

bkg_admin

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 withAND. The following operators and theirrespective equivalents in CQL and XML are supported:

RCQLXML
===PropertyIsEqualTo
!=<>PropertyIsNotEqualTo
<<PropertyIsLessThan
>>PropertyIsGreaterThan
>=>=PropertyIsGreaterThanOrEqualTo
<=<=PropertyIsLessThanOrEqualTo
%LIKE%LIKEPropertyIsLike
%ILIKE%ILIKE
%in%INPropertyIsEqualTo andOr

To construct more complex queries, you can use thefilter argumentto pass CQL queries directly. Also note that you can switch betweenCQL and XML queries usingoptions(ffm_query_language = "xml").See alsowfs_filter.

bbox

An sf geometry or a boundary box vector of the formatc(xmin, ymin, xmax, ymax). Used as a geometric filter to includeonly those geometries that relate tobbox according to the predicatespecified inpredicate. If an sf geometry is provided, coordinatesare automatically transformed to ESPG:25832 (the default CRS), otherwisethey are expected to be in EPSG:25832.

poly

An sf geometry. Used as a geometric filter to includeonly those geometries that relate topoly according to the predicatespecified inpredicate. Coordinates are automatically transformed toESPG:25832 (the default CRS).

predicate

A spatial predicate that is used to relate the outputgeometries with the object specified inbbox orpoly. Forexample, ifpredicate = "within", andbbox is specified,returns only those geometries that lie withinbbox. Can be one of"equals","disjoint","intersects","touches","crosses","within","contains","overlaps","relate","dwithin", or"beyond". Defaults to"intersects".

filter

A character string containing a valid CQL or XML filter. Thisstring is appended to the query constructed through.... Use thisargument to construct more complex filters. Defaults toNULL.

epsg

An EPSG code specifying a coordinate reference system of theoutput. If you're unsure what this means, try runningsf::st_crs(...)$epsg on a spatial object that you are working with.Defaults to 3035.

properties

Vector of columns to include in the output.

max

Maximum number of results to return.

Value

A dataframe containing the following columns:

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

wfs_poi_open documentation

wfs_poi_open MIS record

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"1" (federal states),"2" (inconsistent, something between states and government regions),or"3" (districts). Defaults to federal states.

scale

Scale of the geometries. Can be"250"(1:250,000),"1000" (1:1,000,000),"2500" (1:2,500,000)or"5000" (1:5,000,000). If"250", population data is includedin the output. Defaults to"250".

key_date

Forresolution %in% c("250", "5000"), specifies the keydate from which to download administrative data. Can be either"0101"(January 1) or"1231" (December 31). The latter is able togeoreference statistical data while the first integrates changes madein the new year. If"1231", population data is attached, otherwisenot. Note that population data is not available at all scales (usually250 and 1000). Defaults to "0101".

year

Version year of the dataset. You can uselatest toretrieve the latest dataset version available on the BKG's geodata center.Older versions can be browsed using thearchive.

timeout

Timeout value for the data download passed toreq_timeout. Adjust this if your internet connection isslow or you are downloading larger datasets.

update_cache

By default, downloaded files are cached in thetempdir() directory of R. When downloading the same data again,the data is not downloaded but instead taken from the cache. Sometimesthis can be not the desired behavior. If you want to overwrite the cache,passTRUE. Defaults toFALSE, i.e. always adopt the cacheif possible.

Value

An sf dataframe with multipolygon geometries and the followingcolumns:

Note

This function does not query a WFS so you are only able to downloadentire datasets without the ability to filter beforehand.

See Also

nuts250 documentation

nuts250 MIS record

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 uselatest toretrieve the latest dataset version available on the BKG's geodata center.Older versions can be browsed using thearchive.

region

Subterritory of Germany."all" returns the data forall of Germany,"coast" returns only coastal regions and"no","nw","s" and"w" refer to cardinal directions. Defaultsto"all".

timeout

Timeout value for the data download passed toreq_timeout. Adjust this if your internet connection isslow or you are downloading larger datasets.

update_cache

By default, downloaded files are cached in thetempdir() directory of R. When downloading the same data again,the data is not downloaded but instead taken from the cache. Sometimesthis can be not the desired behavior. If you want to overwrite the cache,passTRUE. Defaults toFALSE, i.e. always adopt the cacheif possible.

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:

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"250"(1:250,000),"1000" (1:1,000,000),"2500" (1:2,500,000)or"5000" (1:5,000,000). If"250", population data is includedin the output. Defaults to"250".

year

Version year of the dataset. You can uselatest toretrieve the latest dataset version available on the BKG's geodata center.Older versions can be browsed using thearchive.

timeout

Timeout value for the data download passed toreq_timeout. Adjust this if your internet connection isslow or you are downloading larger datasets.

update_cache

By default, downloaded files are cached in thetempdir() directory of R. When downloading the same data again,the data is not downloaded but instead taken from the cache. Sometimesthis can be not the desired behavior. If you want to overwrite the cache,passTRUE. Defaults toFALSE, i.e. always adopt the cacheif possible.

Value

An sf tibble with multipolygon geometries and two features,a regional identifier and the region endonyms.

See Also

ge5000 documentation

ge5000 MIS record

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 withAND. The following operators and theirrespective equivalents in CQL and XML are supported:

RCQLXML
===PropertyIsEqualTo
!=<>PropertyIsNotEqualTo
<<PropertyIsLessThan
>>PropertyIsGreaterThan
>=>=PropertyIsGreaterThanOrEqualTo
<=<=PropertyIsLessThanOrEqualTo
%LIKE%LIKEPropertyIsLike
%ILIKE%ILIKE
%in%INPropertyIsEqualTo andOr

To construct more complex queries, you can use thefilter argumentto pass CQL queries directly. Also note that you can switch betweenCQL and XML queries usingoptions(ffm_query_language = "xml").See alsowfs_filter.

bbox

An sf geometry or a boundary box vector of the formatc(xmin, ymin, xmax, ymax). Used as a geometric filter to includeonly those geometries that relate tobbox according to the predicatespecified inpredicate. If an sf geometry is provided, coordinatesare automatically transformed to ESPG:25832 (the default CRS), otherwisethey are expected to be in EPSG:25832.

poly

An sf geometry. Used as a geometric filter to includeonly those geometries that relate topoly according to the predicatespecified inpredicate. Coordinates are automatically transformed toESPG:25832 (the default CRS).

predicate

A spatial predicate that is used to relate the outputgeometries with the object specified inbbox orpoly. Forexample, ifpredicate = "within", andbbox is specified,returns only those geometries that lie withinbbox. Can be one of"equals","disjoint","intersects","touches","crosses","within","contains","overlaps","relate","dwithin", or"beyond". Defaults to"intersects".

filter

A character string containing a valid CQL or XML filter. Thisstring is appended to the query constructed through.... Use thisargument to construct more complex filters. Defaults toNULL.

epsg

An EPSG code specifying a coordinate reference system of theoutput. If you're unsure what this means, try runningsf::st_crs(...)$epsg on a spatial object that you are working with.Defaults to 3035.

properties

Vector of columns to include in the output.

max

Maximum number of results to return.

Value

A dataframe containing the following columns:

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

wfs_poi_open documentation

wfs_poi_open MIS record

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 withAND. The following operators and theirrespective equivalents in CQL and XML are supported:

RCQLXML
===PropertyIsEqualTo
!=<>PropertyIsNotEqualTo
<<PropertyIsLessThan
>>PropertyIsGreaterThan
>=>=PropertyIsGreaterThanOrEqualTo
<=<=PropertyIsLessThanOrEqualTo
%LIKE%LIKEPropertyIsLike
%ILIKE%ILIKE
%in%INPropertyIsEqualTo andOr

To construct more complex queries, you can use thefilter argumentto pass CQL queries directly. Also note that you can switch betweenCQL and XML queries usingoptions(ffm_query_language = "xml").See alsowfs_filter.

bbox

An sf geometry or a boundary box vector of the formatc(xmin, ymin, xmax, ymax). Used as a geometric filter to includeonly those geometries that relate tobbox according to the predicatespecified inpredicate. If an sf geometry is provided, coordinatesare automatically transformed to ESPG:25832 (the default CRS), otherwisethey are expected to be in EPSG:25832.

poly

An sf geometry. Used as a geometric filter to includeonly those geometries that relate topoly according to the predicatespecified inpredicate. Coordinates are automatically transformed toESPG:25832 (the default CRS).

predicate

A spatial predicate that is used to relate the outputgeometries with the object specified inbbox orpoly. Forexample, ifpredicate = "within", andbbox is specified,returns only those geometries that lie withinbbox. Can be one of"equals","disjoint","intersects","touches","crosses","within","contains","overlaps","relate","dwithin", or"beyond". Defaults to"intersects".

filter

A character string containing a valid CQL or XML filter. Thisstring is appended to the query constructed through.... Use thisargument to construct more complex filters. Defaults toNULL.

epsg

An EPSG code specifying a coordinate reference system of theoutput. If you're unsure what this means, try runningsf::st_crs(...)$epsg on a spatial object that you are working with.Defaults to 3035.

properties

Vector of columns to include in the output.

max

Maximum number of results to return.

Value

A dataframe with the following columns:

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

wfs_poi_open documentation

wfs_poi_open MIS record

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 withAND. The following operators and theirrespective equivalents in CQL and XML are supported:

RCQLXML
===PropertyIsEqualTo
!=<>PropertyIsNotEqualTo
<<PropertyIsLessThan
>>PropertyIsGreaterThan
>=>=PropertyIsGreaterThanOrEqualTo
<=<=PropertyIsLessThanOrEqualTo
%LIKE%LIKEPropertyIsLike
%ILIKE%ILIKE
%in%INPropertyIsEqualTo andOr

To construct more complex queries, you can use thefilter argumentto pass CQL queries directly. Also note that you can switch betweenCQL and XML queries usingoptions(ffm_query_language = "xml").See alsowfs_filter.

bbox

An sf geometry or a boundary box vector of the formatc(xmin, ymin, xmax, ymax). Used as a geometric filter to includeonly those geometries that relate tobbox according to the predicatespecified inpredicate. If an sf geometry is provided, coordinatesare automatically transformed to ESPG:25832 (the default CRS), otherwisethey are expected to be in EPSG:25832.

poly

An sf geometry. Used as a geometric filter to includeonly those geometries that relate topoly according to the predicatespecified inpredicate. Coordinates are automatically transformed toESPG:25832 (the default CRS).

predicate

A spatial predicate that is used to relate the outputgeometries with the object specified inbbox orpoly. Forexample, ifpredicate = "within", andbbox is specified,returns only those geometries that lie withinbbox. Can be one of"equals","disjoint","intersects","touches","crosses","within","contains","overlaps","relate","dwithin", or"beyond". Defaults to"intersects".

filter

A character string containing a valid CQL or XML filter. Thisstring is appended to the query constructed through.... Use thisargument to construct more complex filters. Defaults toNULL.

epsg

An EPSG code specifying a coordinate reference system of theoutput. If you're unsure what this means, try runningsf::st_crs(...)$epsg on a spatial object that you are working with.Defaults to 3035.

properties

Vector of columns to include in the output.

max

Maximum number of results to return.

Value

A dataframe containing the following columns:

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

wfs_poi_open documentation

wfs_poi_open MIS record

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 theGetCapabilities of the service.

endpoint

Endpoint to interface. Note thatwcs_ is appendedand only the rest of the product name must be provided. For example,wcs_dgm200_inspire becomesdgm200_inspire. Defaults to thevalue ofcoverage_id.

version

Service version of the WCS. Defaults to2.0.1.

method

HTTP method to use for the request.GET requestsprovide parameters using URL queries. Filters must be provided as CQLqueries. While this is less error-prone, it allows a maximum number ofonly 2048 characters. Especially when providing more sophisticated spatialqueries,GET queries are simply not accepted by the services. Inthese cases it makes sense to usePOST requests instead.

IfNULL, the method is inferred from the type of filter queryprovided tofilter (either XML or CQL). If no filter is provided,the method is inferred fromgetOption("ffm_query_language").

format

Content type of the output. This value heavily dependsthe endpoint queried. Defaults to"image/tiff;application=geotiff".

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. InspecttheGetCapabilities of the target service to find out whichEPSG codes are available. Defaults to EPSG:3035.

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 ofPOST requests, additional namespaces that may be necessary to querythe WFS. Argument names are interpreted as the prefix (e.g.xmlns:wfs) and argument values as namespace links.

Value

ASpatRaster.

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 usebkg_feature_types to retrieve a list of feature type names for agiven endpoint.

endpoint

Endpoint to interface. Note thatwfs_ is appendedand only the rest of the product name must be provided. For example,wfs_vg250 becomesvg250. Defaults to the value oftype_name.

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.GET requestsprovide parameters using URL queries. Filters must be provided as CQLqueries. While this is less error-prone, it allows a maximum number ofonly 2048 characters. Especially when providing more sophisticated spatialqueries,GET queries are simply not accepted by the services. Inthese cases it makes sense to usePOST requests instead.

IfNULL, the method is inferred from the type of filter queryprovided tofilter (either XML or CQL). If no filter is provided,the method is inferred fromgetOption("ffm_query_language").

format

Content type of the output. This value heavily dependsthe endpoint queried. Most services allowapplication/json but someonly support GML outputs. When in doubt, inspect theGetCapabilitiesof the target service. Defaults to"application/json".

layer

Ifformat specifies a GML output,layerspecifies which layer from the downloaded GML file to read. Only necessaryif the GML file actually contains multiple layers. Defaults toNULL.

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. InspecttheGetCapabilities of the target service to find out whichEPSG codes are available. Defaults to EPSG:3035.

properties

Names of columns to include in the output. Defaults toNULL (all columns).

filter

A WFS filter query (CQL or XML) created bywfs_filter.

server

WFS server domain to use. Defaults to the SGX spatial datacenter of the BKG.

...

Further parameters passed to the WFS query. In case ofPOST requests, additional namespaces that may be necessary to querythe WFS. Argument names are interpreted as the prefix (e.g.xmlns:wfs) and argument values as namespace links.

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_nuts3

Format

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

bkg_nuts

Other datasets:admin_data

Examples

bkg_nuts1

WFS 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 withAND. The following operators and theirrespective equivalents in CQL and XML are supported:

RCQLXML
===PropertyIsEqualTo
!=<>PropertyIsNotEqualTo
<<PropertyIsLessThan
>>PropertyIsGreaterThan
>=>=PropertyIsGreaterThanOrEqualTo
<=<=PropertyIsLessThanOrEqualTo
%LIKE%LIKEPropertyIsLike
%ILIKE%ILIKE
%in%INPropertyIsEqualTo andOr

To construct more complex queries, you can use thefilter argumentto pass CQL queries directly. Also note that you can switch betweenCQL and XML queries usingoptions(ffm_query_language = "xml").See alsowfs_filter.

filter

A character string containing a valid CQL or XML filter. Thisstring is appended to the query constructed through.... Use thisargument to construct more complex filters. Defaults toNULL.

bbox

An sf geometry or a boundary box vector of the formatc(xmin, ymin, xmax, ymax). Used as a geometric filter to includeonly those geometries that relate tobbox according to the predicatespecified inpredicate. If an sf geometry is provided, coordinatesare automatically transformed to ESPG:25832 (the default CRS), otherwisethey are expected to be in EPSG:25832.

poly

An sf geometry. Used as a geometric filter to includeonly those geometries that relate topoly according to the predicatespecified inpredicate. Coordinates are automatically transformed toESPG:25832 (the default CRS).

predicate

A spatial predicate that is used to relate the outputgeometries with the object specified inbbox orpoly. Forexample, ifpredicate = "within", andbbox is specified,returns only those geometries that lie withinbbox. Can be one of"equals","disjoint","intersects","touches","crosses","within","contains","overlaps","relate","dwithin", or"beyond". Defaults to"intersects".

geom_property

Name of the geometry property included in the WFS.In most cases, this is"geom", but there are some exceptions.

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 throughbbox orpoly are firsttransformed to this CRS before creating the query.

lang

Query language to use for constructing the query. One of"cql" and"xml". By default, almost allffm functionsuse CQL because it is simpler and less prone to errors. However, CQL islimited in terms of query size. Especially when providing apoly,URLs can become so long that the WFS server will decline them. XML can be avalid alternative to construct large queries. Additionally, some serviceslike the one used bybkg_geonames only support XML. IfNULL, defaults togetOption("ffm_query_language").

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")

[8]ページ先頭

©2009-2025 Movatter.jp