Skip to contents

Returns a tibble with snapshots of Swiss municipality data. A snapshot corresponds to the list of municipalities that are present at least partially during the specified period (or at the specified day when end_date = start_date).

Usage

snapshots(
  start_date = lubridate::today(),
  end_date = start_date,
  historicized_code = FALSE,
  use_cache = TRUE,
  max_cache_age = "1 day"
)

Arguments

start_date

Begin of the period the data covers. A date or a character scalar in the format "YYYY-MM-DD".

end_date

End of the period the data covers. A date or a character scalar in the format "YYYY-MM-DD".

historicized_code

By default, the FSO commune number is returned. Set to TRUE in order to get the historicization number instead.

use_cache

Whether or not to return cached results if possible. If FALSE, results are always newly fetched regardless of max_cache_age.

max_cache_age

Duration after which cached results are refreshed (i.e. newly fetched). A valid lubridate duration. Use Inf to disable cache expiry. Only relevant if use_cache = TRUE. Defaults to 1 day (24 hours).

Value

A tibble.

Details

Note that for technical and organizational reasons, those municipalities that only existed in the period before the first allocation of FSO numbers in 1960 were given the FSO commune number 7700.

FSO commune number vs. historicization number

By default, the FSO commune number is returned. You can set historicized_code = TRUE to get the historicization number instead. Details about the differences between the both can be found in this PDF (in German). A translation of the relevant paragraph (p. 2):

The mutation processes at the cantonal, district and municipal level cause changes in the official register of Swiss municipalities. The so-called historicization number uniquely identifies the entries in the official commune register that have been changed, “deleted” or added as a result of mutation processes.

In contrast to the FSO commune number or district number, the historicization number is unique within the database and defines the state of the communes or districts during a certain period of time. The mutation numbers, the type of inclusion or revocation and the date of inclusion or revocation are used to fully describe the individual mutation events in the “Municipalities” and “Districts” tables. The mutation number identifies the individual mutation events that may affect one or more entries.

The historicization number does not replace the existing municipality and district numbers. It is used for the computer-aided mapping of the various states and mutation processes of the official commune register and the districts.

Examples

swissmuni::snapshots(historicized_code = TRUE)
#> # A tibble: 2,300 × 29
#>    Identifier ValidFrom  ValidTo Level Parent Name_en            Name_fr     Name_de Name_it ABBREV_1_Text_en ABBREV_1_Text_fr ABBREV_1_Text_de ABBREV_1_Text_it
#>         <int> <date>     <date>  <int>  <int> <chr>              <chr>       <chr>   <chr>   <chr>            <chr>            <chr>            <chr>           
#>  1          1 1848-09-12 NA          1     NA Zürich             Zürich      Zürich  Zürich  ZH               ZH               ZH               ZH              
#>  2        101 1848-09-12 NA          2      1 Bezirk Affoltern   Bezirk Aff… Bezirk… Bezirk… Affoltern        Affoltern        Affoltern        Affoltern       
#>  3         13 1848-09-12 NA          3    101 Stallikon          Stallikon   Stalli… Stalli… NA               NA               NA               NA              
#>  4          2 1848-09-12 NA          3    101 Affoltern am Albis Affoltern … Affolt… Affolt… NA               NA               NA               NA              
#>  5          3 1848-09-12 NA          3    101 Bonstetten         Bonstetten  Bonste… Bonste… NA               NA               NA               NA              
#>  6          4 1911-01-01 NA          3    101 Hausen am Albis    Hausen am … Hausen… Hausen… NA               NA               NA               NA              
#>  7          5 1848-09-12 NA          3    101 Hedingen           Hedingen    Heding… Heding… NA               NA               NA               NA              
#>  8          9 1848-09-12 NA          3    101 Mettmenstetten     Mettmenste… Mettme… Mettme… NA               NA               NA               NA              
#>  9         10 1848-09-12 NA          3    101 Obfelden           Obfelden    Obfeld… Obfeld… NA               NA               NA               NA              
#> 10          6 1911-01-01 NA          3    101 Kappel am Albis    Kappel am … Kappel… Kappel… NA               NA               NA               NA              
#> # ℹ 2,290 more rows
#> # ℹ 16 more variables: ABBREV_1_Text <chr>, CODE_HIST_1_Text_en <chr>, CODE_HIST_1_Text_fr <chr>, CODE_HIST_1_Text_de <chr>, CODE_HIST_1_Text_it <chr>,
#> #   CODE_HIST_1_Text <chr>, INSCRIPTION_1_Text_en <chr>, INSCRIPTION_1_Text_fr <chr>, INSCRIPTION_1_Text_de <chr>, INSCRIPTION_1_Text_it <chr>,
#> #   INSCRIPTION_1_Text <chr>, REC_TYPE_1_Text_en <chr>, REC_TYPE_1_Text_fr <chr>, REC_TYPE_1_Text_de <chr>, REC_TYPE_1_Text_it <chr>, REC_TYPE_1_Text <chr>