View source: R/bfs_get_base_maps.R
| bfs_get_base_maps | R Documentation |
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
)
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.
bfs_clear_cache()
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.