| Title: | Get Data from the Swiss Federal Statistical Office |
|---|---|
| Description: | Search and download data from the Swiss Federal Statistical Office (BFS) APIs <https://www.bfs.admin.ch/>. |
| Authors: | Felix Luginbuhl [aut, cre, cph] (ORCID: <https://orcid.org/0009-0008-6625-2899>), Marius Hodel [ctb] (ORCID: <https://orcid.org/0000-0001-8789-506X>), Janosch Brenzel-Weiss [ctb], Joao Martins [ctb], Philipp Baumann [ctb] (ORCID: <https://orcid.org/0000-0002-3194-8975>) |
| Maintainer: | Felix Luginbuhl <[email protected]> |
| License: | GPL (>= 3) |
| Version: | 0.8.0 |
| Built: | 2026-10-18 14:49:02 UTC |
| Source: | https://github.com/lgnbhl/BFS |
Delete the base maps cached by bfs_get_base_maps() in
tools::R_user_dir(package = "BFS") and the list of Swiss Stats Explorer
datasets cached for the R session by bfs_get_sse_data() and
bfs_get_sse_metadata(). The cached data is downloaded again when needed.
bfs_sse_datasets(), bfs_sse_dimensions() and bfs_sse_data() don't
cache anything.
bfs_clear_cache()bfs_clear_cache()
Invisibly, the path of the deleted cache folder.
bfs_clear_cache()bfs_clear_cache()
Download any file of the BFS (Excel, CSV, PX, PDF, zip, ...) from the DAM
API (https://dam-api.bfs.admin.ch/hub/swagger-ui/index.html) with its
asset number or its BFS number. Use it for the tables of
bfs_get_catalog_tables(), or for datasets too large for
bfs_get_data().
bfs_download_asset( number_asset = NULL, number_bfs = NULL, destfile, quiet = TRUE, mode = "wb", handle = curl::new_handle() )bfs_download_asset( number_asset = NULL, number_bfs = NULL, destfile, quiet = TRUE, mode = "wb", handle = curl::new_handle() )
number_asset |
The asset number of the file, e.g. |
number_bfs |
The BFS number of the file, e.g.
|
destfile |
Path of the downloaded file. |
quiet |
If |
mode, handle
|
Passed to |
The path of the downloaded file. Returns NULL if there is no
internet connection.
bfs_get_asset_metadata(), bfs_get_catalog_tables()
# a PX file, read it with pxR::read.px() bfs_download_asset( number_bfs = "px-x-1502040100_131", destfile = file.path(tempdir(), "px-x-1502040100_131.px") )# a PX file, read it with pxR::read.px() bfs_download_asset( number_bfs = "px-x-1502040100_131", destfile = file.path(tempdir(), "px-x-1502040100_131.px") )
Download the files of a geodata collection from the STAC API of the Swiss geo-portal (https://data.geo.admin.ch/api/stac/v0.9/). Requires the rstac package.
bfs_download_geodata( collection_id, output_dir = tempdir(), overwrite = FALSE, create_json = FALSE, bbox = NULL, asset_names = NULL, datetime = NULL, feature_id = NULL )bfs_download_geodata( collection_id, output_dir = tempdir(), overwrite = FALSE, create_json = FALSE, bbox = NULL, asset_names = NULL, datetime = NULL, feature_id = NULL )
collection_id |
The collection id, i.e. the |
output_dir |
Folder of the downloaded files, a temporary folder by default. |
overwrite |
If |
create_json |
If |
bbox, datetime, feature_id
|
Optional filters of the items: bounding
box, date-time or interval, and item id. See |
asset_names |
Optional names of the assets to download. See
|
The use of the data is free but subject to the terms of use of the Swiss geo-portal (https://www.geo.admin.ch/terms-of-use).
The paths of the downloaded files. Zip files are not extracted.
Returns NULL if there is no internet connection.
files <- bfs_download_geodata( collection_id = "ch.bfs.generalisierte-grenzen_agglomerationen_g1" ) filesfiles <- bfs_download_geodata( collection_id = "ch.bfs.generalisierte-grenzen_agglomerationen_g1" ) files
Get the metadata of a BFS file from the DAM API (https://dam-api.bfs.admin.ch/hub/swagger-ui/index.html) with its asset number or its BFS number: title, description, publication date, contact, links, ...
bfs_get_asset_metadata( number_asset = NULL, number_bfs = NULL, language = c("de", "fr", "it", "en") )bfs_get_asset_metadata( number_asset = NULL, number_bfs = NULL, language = c("de", "fr", "it", "en") )
number_asset |
The asset number of the file, e.g. |
number_bfs |
The BFS number of the file, e.g.
|
language |
Language of the metadata: |
A nested list with the metadata. Returns NULL if there is no
internet connection.
metadata <- bfs_get_asset_metadata(number_bfs = "px-x-1502040100_131", language = "en") metadata$description$titles$mainmetadata <- bfs_get_asset_metadata(number_bfs = "px-x-1502040100_131", language = "en") metadata$description$titles$main
Get the cartographic base maps of the BFS ThemaKart project: the borders of Switzerland, cantons, districts and communes, lakes, rivers, ... The names of the geometries and files are in the BFS documentation (https://www.bfs.admin.ch/bfs/en/home/statistics/regional-statistics/base-maps/cartographic-bases.html). Please read its terms of use and copyright notices.
bfs_get_base_maps( geom = NULL, category = "gf", type = "Poly", date = NULL, most_recent = TRUE, format = "shp", asset_number = "30566934", return_sf = TRUE )bfs_get_base_maps( geom = NULL, category = "gf", type = "Poly", date = NULL, most_recent = TRUE, format = "shp", asset_number = "30566934", return_sf = TRUE )
geom |
Geometry, e.g. |
category |
Category: |
type |
|
date |
Optional date of validity, as |
most_recent |
If |
format |
File format, |
asset_number |
Asset number of the ThemaKart zip file. The default is
the 2024 edition; e.g. |
return_sf |
If |
The base maps are a zip file of several hundred files, downloaded once and
cached in tools::R_user_dir("BFS"). Use bfs_clear_cache() to delete it.
Each file name combines the arguments, e.g.
K4kant20220101gf_ch2007Poly.shp: geometry kant, date 20220101,
category gf, type Poly, format shp.
An sf object, or with return_sf = FALSE the file path(s). Returns NULL if there is no internet connection and
the base maps are not cached yet.
cantons <- bfs_get_base_maps(geom = "kant") plot(sf::st_geometry(cantons)) lakes <- bfs_get_base_maps(geom = "seen", category = "11") rivers <- bfs_get_base_maps(geom = "flus", category = "22", type = "") # list all river files bfs_get_base_maps(geom = "flus", category = "", type = "", date = "", return_sf = FALSE)cantons <- bfs_get_base_maps(geom = "kant") plot(sf::st_geometry(cantons)) lakes <- bfs_get_base_maps(geom = "seen", category = "11") rivers <- bfs_get_base_maps(geom = "flus", category = "22", type = "") # list all river files bfs_get_base_maps(geom = "flus", category = "", type = "", date = "", return_sf = FALSE)
Search the datasets of the BFS catalog
(https://www.bfs.admin.ch/bfs/en/home/statistics/catalogue.html, article
type "Data") that can be downloaded with bfs_get_data().
bfs_get_catalog_data( language = "de", title = NULL, extended_search = NULL, spatial_division = NULL, prodima = NULL, inquiry = NULL, institution = NULL, publishing_year_start = NULL, publishing_year_end = NULL, order_nr = NULL, limit = 1000, article_model = 900033, article_model_group = 900029, return_raw = FALSE )bfs_get_catalog_data( language = "de", title = NULL, extended_search = NULL, spatial_division = NULL, prodima = NULL, inquiry = NULL, institution = NULL, publishing_year_start = NULL, publishing_year_end = NULL, order_nr = NULL, limit = 1000, article_model = 900033, article_model_group = 900029, return_raw = FALSE )
language |
Language of the catalog: |
title |
Text to search in the titles. |
extended_search |
Text to search in the titles, BFS number and summaries. |
spatial_division |
Spatial division of the datasets: |
prodima |
Theme number(s) of the BFS, e.g. |
inquiry |
Inquiry (survey) id. |
institution |
Institution id. |
publishing_year_start, publishing_year_end
|
First and last publishing year. |
order_nr |
BFS number, e.g. |
limit |
Maximum number of results (1000 by default). A message tells
you when the catalog has as many results as |
article_model, article_model_group
|
Article type ids of the DAM API. The defaults select the "Data" (or "Tables") article type; you don't need to change them. |
return_raw |
If |
The English and Italian catalogs have fewer datasets than the German and
French ones. Arguments accept several values, e.g.
prodima = c(900210, 900212).
A tibble with the columns:
Title of the dataset.
Language of the catalog.
BFS number, to use in bfs_get_data().
Asset number, to use in bfs_download_asset().
Publication date.
URL of the dataset in the PXWeb API.
Returns NULL if there is no internet connection.
bfs_get_data(), bfs_get_catalog_tables()
bfs_get_catalog_data(language = "en", extended_search = "student") # by theme ("Education and science") bfs_get_catalog_data(language = "en", prodima = 900212)bfs_get_catalog_data(language = "en", extended_search = "student") # by theme ("Education and science") bfs_get_catalog_data(language = "en", prodima = 900212)
List the geodata collections of the STAC API of the Swiss geo-portal
(https://data.geo.admin.ch/), from the BFS and other federal offices.
Download a collection with bfs_download_geodata().
bfs_get_catalog_geodata(include_metadata = TRUE)bfs_get_catalog_geodata(include_metadata = TRUE)
include_metadata |
If |
A tibble with one row per collection: collection_id, type and
href, and with include_metadata = TRUE, title, description,
created, updated, crs, license, provider_name, bbox and
inverval. Returns NULL if there is no internet connection.
catalog_geodata <- bfs_get_catalog_geodata() # the collections of the BFS catalog_geodata[grepl("^ch.bfs", catalog_geodata$collection_id), ]catalog_geodata <- bfs_get_catalog_geodata() # the collections of the BFS catalog_geodata[grepl("^ch.bfs", catalog_geodata$collection_id), ]
Search the tables of the BFS catalog
(https://www.bfs.admin.ch/bfs/en/home/statistics/catalogue.html, article
type "Tables"). Tables are mostly Excel or CSV files, not available in the
PXWeb API: download them with bfs_download_asset().
bfs_get_catalog_tables( language = "de", title = NULL, extended_search = NULL, spatial_division = NULL, prodima = NULL, inquiry = NULL, institution = NULL, publishing_year_start = NULL, publishing_year_end = NULL, order_nr = NULL, limit = 1000, article_model = 900030, article_model_group = 900029, return_raw = FALSE )bfs_get_catalog_tables( language = "de", title = NULL, extended_search = NULL, spatial_division = NULL, prodima = NULL, inquiry = NULL, institution = NULL, publishing_year_start = NULL, publishing_year_end = NULL, order_nr = NULL, limit = 1000, article_model = 900030, article_model_group = 900029, return_raw = FALSE )
language |
Language of the catalog: |
title |
Text to search in the titles. |
extended_search |
Text to search in the titles, BFS number and summaries. |
spatial_division |
Spatial division of the datasets: |
prodima |
Theme number(s) of the BFS, e.g. |
inquiry |
Inquiry (survey) id. |
institution |
Institution id. |
publishing_year_start, publishing_year_end
|
First and last publishing year. |
order_nr |
BFS number, e.g. |
limit |
Maximum number of results (1000 by default). A message tells
you when the catalog has as many results as |
article_model, article_model_group
|
Article type ids of the DAM API. The defaults select the "Data" (or "Tables") article type; you don't need to change them. |
return_raw |
If |
The English and Italian catalogs have fewer tables than the German and
French ones. Arguments accept several values, e.g.
prodima = c(900210, 900212).
A tibble with the columns:
Title of the table.
Language of the catalog.
Asset number, to use in bfs_download_asset().
Publication date.
BFS number.
Returns NULL if there is no internet connection.
bfs_download_asset(), bfs_get_catalog_data()
tables <- bfs_get_catalog_tables(language = "en", extended_search = "students") tables # download the first table bfs_download_asset( number_asset = tables$number_asset[1], destfile = file.path(tempdir(), "table.xlsx") )tables <- bfs_get_catalog_tables(language = "en", extended_search = "students") tables # download the first table bfs_download_asset( number_asset = tables$number_asset[1], destfile = file.path(tempdir(), "table.xlsx") )
Download a dataset from the PXWeb API of the BFS with its BFS number.
Find the BFS number with bfs_get_catalog_data() or on the BFS website.
bfs_get_data( number_bfs, language = "de", query = NULL, column_name_type = "text", variable_value_type = "text", clean_names = FALSE, delay = NULL )bfs_get_data( number_bfs, language = "de", query = NULL, column_name_type = "text", variable_value_type = "text", clean_names = FALSE, delay = NULL )
number_bfs |
The BFS number of a dataset, e.g.
|
language |
Language of the dataset: |
query |
Optional selection of the data: a named list with the
variable codes as names and the value codes as values (columns |
column_name_type |
Column names as |
variable_value_type |
Values as |
clean_names |
If |
delay |
Optional number of seconds to wait before downloading the data, to avoid "Too Many Requests" errors when calling the API in a loop. |
Large datasets can exceed the limits of the API: select only the data you
need with query, or download the whole file with bfs_download_asset().
The PXWeb API is the API of STAT-TAB, which the BFS is replacing with the
Swiss Stats Explorer: check first if the statistic is on
https://stats.swiss/ and use bfs_sse_data().
A tibble. Returns NULL if there is no internet connection.
bfs_get_catalog_data(), bfs_get_metadata(),
bfs_get_data_comments()
# whole dataset bfs_get_data(number_bfs = "px-x-1502040100_131", language = "en") # only some years and levels of study bfs_get_data( number_bfs = "px-x-1502040100_131", language = "en", query = list(Jahr = c("40", "41"), Studienstufe = c("2", "3")) )# whole dataset bfs_get_data(number_bfs = "px-x-1502040100_131", language = "en") # only some years and levels of study bfs_get_data( number_bfs = "px-x-1502040100_131", language = "en", query = list(Jahr = c("40", "41"), Studienstufe = c("2", "3")) )
Get the comments (footnotes) of a dataset of the PXWeb API, e.g. on provisional values or changes of definition.
bfs_get_data_comments( number_bfs, language = "de", query = NULL, clean_names = FALSE, delay = NULL )bfs_get_data_comments( number_bfs, language = "de", query = NULL, clean_names = FALSE, delay = NULL )
number_bfs |
The BFS number of a dataset, e.g.
|
language |
Language of the dataset: |
query |
Optional selection of the data: a named list with the
variable codes as names and the value codes as values (columns |
clean_names |
If |
delay |
Optional number of seconds to wait before downloading the data, to avoid "Too Many Requests" errors when calling the API in a loop. |
The PXWeb API is the API of STAT-TAB, which the BFS is replacing with the Swiss Stats Explorer.
A tibble with one row per comment. Returns NULL if there is no
internet connection.
bfs_get_data_comments(number_bfs = "px-x-1502040100_131", language = "en")bfs_get_data_comments(number_bfs = "px-x-1502040100_131", language = "en")
Get the variables of a dataset of the PXWeb API and the values each
variable can take. Use them to build the query of bfs_get_data().
bfs_get_metadata(number_bfs, language = "de")bfs_get_metadata(number_bfs, language = "de")
number_bfs |
The BFS number of a dataset, e.g.
|
language |
Language of the dataset: |
The PXWeb API is the API of STAT-TAB, which the BFS is replacing with the
Swiss Stats Explorer (see bfs_sse_dimensions()).
A tibble with one row per variable and the columns code and
text (variable code and label), values and valueTexts (list
columns with the value codes and labels) and title (title of the
dataset). Use tidyr::unnest_longer(metadata, c(values, valueTexts)) to
get one row per value. Returns NULL if there is no internet
connection.
metadata <- bfs_get_metadata(number_bfs = "px-x-1502040100_131", language = "en") metadata # one row per value tidyr::unnest_longer(metadata, c(values, valueTexts))metadata <- bfs_get_metadata(number_bfs = "px-x-1502040100_131", language = "en") metadata # one row per value tidyr::unnest_longer(metadata, c(values, valueTexts))
Deprecated since BFS 0.8.0: use bfs_sse_data() instead. It downloads the
data faster and stops on a query that wouldn't filter the data. This
function still works and gets only bug fixes, e.g. the labels of codes
with no name in language (see NEWS). To move your code, see the article
Moving to the new Swiss Stats Explorer functions.
Download a dataset of the Swiss Stats Explorer (SSE) API
(https://stats.swiss/). Select the data you need with query, built
from the codelists of bfs_get_sse_metadata().
bfs_get_sse_data( number_bfs, language = "de", start_period = NULL, end_period = NULL, query = NULL, column_name_type = "code", variable_value_type = "text", clean_names = FALSE )bfs_get_sse_data( number_bfs, language = "de", start_period = NULL, end_period = NULL, query = NULL, column_name_type = "code", variable_value_type = "text", clean_names = FALSE )
number_bfs |
The id of an SSE dataset (dataflow), e.g. |
language |
Language of the labels: |
start_period, end_period
|
Optional first and last period of the data,
e.g. |
query |
A named list: the names are dimension codes (column |
column_name_type |
Column names as dimension |
variable_value_type |
Values as |
clean_names |
If |
A tibble with one column per dimension and the observations in
the value column. Returns NULL if there is no internet connection.
Marius Hodel
bfs_sse_data(), bfs_get_sse_metadata()
bfs_get_sse_data( number_bfs = "DF_PASTA_552_MONTHLY", language = "en", query = list( FREQ = "M", ACCOMMODATION_TYPE = "552001", COUNTRY_ORIGIN = c("CH", "AUSL") ), start_period = "2020", end_period = "2023" )bfs_get_sse_data( number_bfs = "DF_PASTA_552_MONTHLY", language = "en", query = list( FREQ = "M", ACCOMMODATION_TYPE = "552001", COUNTRY_ORIGIN = c("CH", "AUSL") ), start_period = "2020", end_period = "2023" )
Deprecated since BFS 0.8.0: use bfs_sse_dimensions() instead. This
function still works and gets only bug fixes, e.g. the labels of codes
with no name in language (see NEWS). To move your code, see the article
Moving to the new Swiss Stats Explorer functions.
Get the dimensions of a dataset of the Swiss Stats Explorer (SSE) API
(https://stats.swiss/) and the values each dimension can take. Use them
to build the query of bfs_get_sse_data().
bfs_get_sse_metadata(number_bfs, language = "de")bfs_get_sse_metadata(number_bfs, language = "de")
number_bfs |
The id of an SSE dataset (dataflow), e.g. |
language |
Language of the labels: |
A tibble with one row per value of each dimension:
The dimension code, to use as a name in query.
The dimension label.
The value code, to use as a value in query.
The value label.
The position of the dimension in the dataset.
Returns NULL if there is no internet connection.
Marius Hodel
bfs_sse_dimensions(), bfs_get_sse_data()
codelist <- bfs_get_sse_metadata("DF_LWZ_1", language = "en") codelist # the dimensions and their codes unique(codelist[c("code", "text")])codelist <- bfs_get_sse_metadata("DF_LWZ_1", language = "en") codelist # the dimensions and their codes unique(codelist[c("code", "text")])
Download the data of a dataset of the Swiss Stats Explorer (SSE) API
(https://stats.swiss/). Select the data you need with filters, built
from bfs_sse_dimensions().
bfs_sse_data( dataset, ..., filters = NULL, start_period = NULL, end_period = NULL, first_n = NULL, last_n = NULL, language = "de", labels = c("both", "code", "label"), attributes = FALSE, version = NULL )bfs_sse_data( dataset, ..., filters = NULL, start_period = NULL, end_period = NULL, first_n = NULL, last_n = NULL, language = "de", labels = c("both", "code", "label"), attributes = FALSE, version = NULL )
dataset |
The id of a dataset, e.g. |
... |
These dots are for future extensions and must be empty: the
arguments after |
filters |
A named list: the names are dimensions (column |
start_period, end_period
|
Optional first and last period of the data,
e.g. |
first_n, last_n
|
Optional number of first or last periods of each
series (each combination of the dimensions), e.g. |
language |
Language of the labels: |
labels |
The values of the dimensions and attributes: |
attributes |
If |
version |
Version of the dataset, e.g. |
The data is downloaded in the SDMX-CSV format, with the labels in
language given by the API. It is smaller and faster to read than the
SDMX-ML format used by bfs_get_sse_data().
The function sends two requests: one for the dimensions of the dataset, to
build the query from filters, and one for the data. The values in
filters are checked by the API: a value not in the dataset gives no
data.
A tibble with one column per dimension, named with the dimension
id whatever the language, then TIME_PERIOD as text (e.g. "2024",
"2024-Q1", "2024-01"), as given by the API, and the observations in
the numeric value column. Returns NULL if there is no internet
connection. The errors have a class, to handle them with
tryCatch():
bfs_no_recordsNo data matches the query.
bfs_sse_filter_errorfilters wouldn't filter the data, e.g.
an unknown dimension.
bfs_sse_argument_errorAnother argument is not valid.
bfs_sse_dataset_errorThe dataset or the version doesn't exist.
bfs_sse_query_errorThe API rejects the query, e.g. a period in a wrong format or a URL too long. The error gives the message of the API.
bfs_http_errorThe API is not available.
Felix Luginbuhl
bfs_sse_datasets(), bfs_sse_dimensions()
bfs_sse_data( "DF_PASTA_552_MONTHLY", filters = list( FREQ = "M", ACCOMMODATION_TYPE = "552001", COUNTRY_ORIGIN = c("CH", "AUSL") ), start_period = "2020", end_period = "2023", language = "en" ) # the latest vacancy rate of each canton bfs_sse_data( "DF_LWZ_1", filters = list( GR_KT_GDE = c("GE", "ZH", "BE"), WOHN_ANZAHL = "_T", LEERWOHN_TYP = "_T", MEASURE_DIMENSION = "RATE" ), last_n = 1, language = "en" )bfs_sse_data( "DF_PASTA_552_MONTHLY", filters = list( FREQ = "M", ACCOMMODATION_TYPE = "552001", COUNTRY_ORIGIN = c("CH", "AUSL") ), start_period = "2020", end_period = "2023", language = "en" ) # the latest vacancy rate of each canton bfs_sse_data( "DF_LWZ_1", filters = list( GR_KT_GDE = c("GE", "ZH", "BE"), WOHN_ANZAHL = "_T", LEERWOHN_TYP = "_T", MEASURE_DIMENSION = "RATE" ), last_n = 1, language = "en" )
List the datasets (dataflows) of the Swiss Stats Explorer (SSE) API
(https://stats.swiss/), to find the id of a dataset for
bfs_sse_dimensions() and bfs_sse_data().
bfs_sse_datasets(language = "de")bfs_sse_datasets(language = "de")
language |
Language of the names: |
A tibble with one row per version of each dataset, the latest version first:
The id of the dataset, e.g. "DF_LWZ_1".
The name of the dataset.
The version of the dataset.
The agency publishing the dataset.
The description of the dataset version, or NA, as
given by the API: it can contain HTML tags such as <br>.
Returns NULL if there is no internet connection.
Felix Luginbuhl
bfs_sse_dimensions(), bfs_sse_data()
datasets <- bfs_sse_datasets(language = "en") datasets # datasets about tourism, in their name or description datasets[grepl("touris", paste(datasets$name, datasets$description), ignore.case = TRUE), ]datasets <- bfs_sse_datasets(language = "en") datasets # datasets about tourism, in their name or description datasets[grepl("touris", paste(datasets$name, datasets$description), ignore.case = TRUE), ]
Get the dimensions of a dataset of the Swiss Stats Explorer (SSE) API
(https://stats.swiss/) and the values allowed in each dimension. Use
them to build the filters of bfs_sse_data().
bfs_sse_dimensions(dataset, ..., language = "de", version = NULL)bfs_sse_dimensions(dataset, ..., language = "de", version = NULL)
dataset |
The id of a dataset, e.g. |
... |
These dots are for future extensions and must be empty: the
arguments after |
language |
Language of the labels: |
version |
Version of the dataset, e.g. |
A tibble with one row per value allowed in each dimension (some values may have no data):
The dimension id, to use as a name in filters.
The dimension label.
The value code, to use as a value in filters.
The value label.
The position of the dimension in the dataset.
The code of the parent value in the codelist, e.g. the
district of a commune and the canton of a district, or NA. Use it to
select all the values under a value.
Returns NULL if there is no internet connection.
Felix Luginbuhl
bfs_sse_datasets(), bfs_sse_data()
dimensions <- bfs_sse_dimensions("DF_PASTA_552_MONTHLY", language = "en") dimensions # the dimensions only unique(dimensions[c("dimension", "dimension_label")]) # the communes of the canton of Geneva: the values whose parent is a # district of Geneva regions <- bfs_sse_dimensions("DF_LWZ_1", language = "en") districts <- regions$value[regions$parent %in% "GE"] regions[regions$parent %in% districts, ]dimensions <- bfs_sse_dimensions("DF_PASTA_552_MONTHLY", language = "en") dimensions # the dimensions only unique(dimensions[c("dimension", "dimension_label")]) # the communes of the canton of Geneva: the values whose parent is a # district of Geneva regions <- bfs_sse_dimensions("DF_LWZ_1", language = "en") districts <- regions$value[regions$parent %in% "GE"] regions[regions$parent %in% districts, ]
The districts of Switzerland (or comparable administrative entities) on 1 January 2023.
register_bznregister_bzn
A data frame with 143 rows and 3 columns:
Canton abbreviation, e.g. "ZH".
District number.
District name.
https://www.bfs.admin.ch/bfs/en/home/basics/swiss-official-commune-register.html
Other commune register:
register_dic,
register_gde,
register_gde_other,
register_kt,
register_kt_seeanteile
The variables of the commune register datasets, in German, French and Italian.
register_dicregister_dic
A data frame with 27 rows and 5 columns:
Language: "de", "fr" or "it".
Variable name, e.g. "GDENR".
Variable label.
Specifications.
General notes.
https://www.bfs.admin.ch/bfs/en/home/basics/swiss-official-commune-register.html
Other commune register:
register_bzn,
register_gde,
register_gde_other,
register_kt,
register_kt_seeanteile
The communes of Switzerland on 1 January 2023, with their district and canton. The BFS assigns a number to each commune and publishes the Swiss official commune register, used by the federal, cantonal and communal administrations to identify communes. See register_dic for the variables in German, French and Italian.
register_gderegister_gde
A data frame with 2,136 rows and 8 columns:
Canton abbreviation, e.g. "ZH".
District number.
BFS commune number.
Official commune name.
Short commune name.
District name.
Canton name.
Date of the last change, as "dd.mm.yyyy".
https://www.bfs.admin.ch/bfs/en/home/basics/swiss-official-commune-register.html
Other commune register:
register_bzn,
register_dic,
register_gde_other,
register_kt,
register_kt_seeanteile
The areas of Switzerland that belong to no commune (e.g. the Staatswald Galm), on 1 January 2023.
register_gde_otherregister_gde_other
A data frame with 3 rows and 4 columns:
BFS number of the area.
Name of the area.
Canton number.
District number.
https://www.bfs.admin.ch/bfs/en/home/basics/swiss-official-commune-register.html
Other commune register:
register_bzn,
register_dic,
register_gde,
register_kt,
register_kt_seeanteile
The 26 cantons of Switzerland.
register_ktregister_kt
A data frame with 26 rows and 3 columns:
Canton number.
Canton abbreviation, e.g. "ZH".
Canton name.
https://www.bfs.admin.ch/bfs/en/home/basics/swiss-official-commune-register.html
Other commune register:
register_bzn,
register_dic,
register_gde,
register_gde_other,
register_kt_seeanteile
The lakes of Switzerland, split by canton (e.g. "Zürichsee (ZH)" and "Zürichsee (SZ)"), on 1 January 2023.
register_kt_seeanteileregister_kt_seeanteile
A data frame with 41 rows and 3 columns:
BFS number of the lake share.
Name of the lake share.
Canton number.
https://www.bfs.admin.ch/bfs/en/home/basics/swiss-official-commune-register.html
Other commune register:
register_bzn,
register_dic,
register_gde,
register_gde_other,
register_kt